<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">--</span><span>
</span><span id="line-2"></span><span class="hs-comment">-- Copyright (c) 2018 Andreas Klebinger</span><span>
</span><span id="line-3"></span><span class="hs-comment">--</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# LANGUAGE DataKinds #-}</span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE ScopedTypeVariables #-}</span><span>
</span><span id="line-8"></span><span class="hs-pragma">{-# LANGUAGE TypeFamilies #-}</span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# LANGUAGE GeneralizedNewtypeDeriving #-}</span><span>
</span><span id="line-10"></span><span class="hs-pragma">{-# LANGUAGE FlexibleContexts #-}</span><span>
</span><span id="line-11"></span><span>
</span><span id="line-12"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.CmmToAsm.BlockLayout</span><span>
</span><span id="line-13"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#sequenceTop"><span class="hs-identifier">sequenceTop</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#backendMaintainsCfg"><span class="hs-identifier">backendMaintainsCfg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-14"></span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html"><span class="hs-identifier">GHC.CmmToAsm.Instr</span></a></span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Monad.html"><span class="hs-identifier">GHC.CmmToAsm.Monad</span></a></span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html"><span class="hs-identifier">GHC.CmmToAsm.CFG</span></a></span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html"><span class="hs-identifier">GHC.Cmm.BlockId</span></a></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.html"><span class="hs-identifier">GHC.Cmm</span></a></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Collections.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Collections</span></a></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Label</span></a></span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier">gopt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Driver.Flags.html#GeneralFlag"><span class="hs-identifier">GeneralFlag</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier">DynFlags</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier">targetPlatform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html"><span class="hs-identifier">GHC.Types.Unique.FM</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Directed.html"><span class="hs-identifier">GHC.Data.Graph.Directed</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-comment">-- DEBUGGING ONLY</span><span>
</span><span id="line-38"></span><span class="hs-comment">--import GHC.Cmm.DebugBlock</span><span>
</span><span id="line-39"></span><span class="hs-comment">--import Debug.Trace</span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.List.SetOps.html"><span class="hs-identifier">GHC.Data.List.SetOps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.List.SetOps.html#removeDups"><span class="hs-identifier">removeDups</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-41"></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.OrdList.html"><span class="hs-identifier">GHC.Data.OrdList</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.OldList.html#sortOn"><span class="hs-identifier">sortOn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#sortBy"><span class="hs-identifier">sortBy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#nub"><span class="hs-identifier">nub</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#"><span class="hs-identifier">Data.Foldable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Foldable.html#toList"><span class="hs-identifier">toList</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.html#"><span class="hs-identifier">Data.Set</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Set</span></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.STRef.html#"><span class="hs-identifier">Data.STRef</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.ST.Strict.html#"><span class="hs-identifier">Control.Monad.ST.Strict</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Control.Monad.html#foldM"><span class="hs-identifier">foldM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier">unless</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.UnionFind.html"><span class="hs-identifier">GHC.Data.UnionFind</span></a></span><span>
</span><span id="line-51"></span><span>
</span><span id="line-52"></span><span class="hs-comment">{-
  Note [CFG based code layout]
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  The major steps in placing blocks are as follow:
  * Compute a CFG based on the Cmm AST, see getCfgProc.
    This CFG will have edge weights representing a guess
    on how important they are.
  * After we convert Cmm to Asm we run `optimizeCFG` which
    adds a few more &quot;educated guesses&quot; to the equation.
  * Then we run loop analysis on the CFG (`loopInfo`) which tells us
    about loop headers, loop nesting levels and the sort.
  * Based on the CFG and loop information refine the edge weights
    in the CFG and normalize them relative to the most often visited
    node. (See `mkGlobalWeights`)
  * Feed this CFG into the block layout code (`sequenceTop`) in this
    module. Which will then produce a code layout based on the input weights.

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ~~~ Note [Chain based CFG serialization]
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  For additional information also look at
  https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/code-layout

  We have a CFG with edge weights based on which we try to place blocks next to
  each other.

  Edge weights not only represent likelihood of control transfer between blocks
  but also how much a block would benefit from being placed sequentially after
  it's predecessor.
  For example blocks which are preceded by an info table are more likely to end
  up in a different cache line than their predecessor and we can't eliminate the jump
  so there is less benefit to placing them sequentially.

  For example consider this example:

  A:  ...
      jmp cond D (weak successor)
      jmp B
  B:  ...
      jmp C
  C:  ...
      jmp X
  D:  ...
      jmp B (weak successor)

  We determine a block layout by building up chunks (calling them chains) of
  possible control flows for which blocks will be placed sequentially.

  Eg for our example we might end up with two chains like:
  [A-&gt;B-&gt;C-&gt;X],[D]. Blocks inside chains will always be placed sequentially.
  However there is no particular order in which chains are placed since
  (hopefully) the blocks for which sequentiality is important have already
  been placed in the same chain.

  -----------------------------------------------------------------------------
     1) First try to create a list of good chains.
  -----------------------------------------------------------------------------

  Good chains are these which allow us to eliminate jump instructions.
  Which further eliminate often executed jumps first.

  We do so by:

  *)  Ignore edges which represent instructions which can not be replaced
      by fall through control flow. Primarily calls and edges to blocks which
      are prefixed by a info table we have to jump across.

  *)  Then process remaining edges in order of frequency taken and:

    +)  If source and target have not been placed build a new chain from them.

    +)  If source and target have been placed, and are ends of differing chains
        try to merge the two chains.

    +)  If one side of the edge is a end/front of a chain, add the other block of
        to edge to the same chain

        Eg if we look at edge (B -&gt; C) and already have the chain (A -&gt; B)
        then we extend the chain to (A -&gt; B -&gt; C).

    +)  If the edge was used to modify or build a new chain remove the edge from
        our working list.

  *) If there any blocks not being placed into a chain after these steps we place
     them into a chain consisting of only this block.

  Ranking edges by their taken frequency, if
  two edges compete for fall through on the same target block, the one taken
  more often will automatically win out. Resulting in fewer instructions being
  executed.

  Creating singleton chains is required for situations where we have code of the
  form:

    A: goto B:
    &lt;infoTable&gt;
    B: goto C:
    &lt;infoTable&gt;
    C: ...

  As the code in block B is only connected to the rest of the program via edges
  which will be ignored in this step we make sure that B still ends up in a chain
  this way.

  -----------------------------------------------------------------------------
     2) We also try to fuse chains.
  -----------------------------------------------------------------------------

  As a result from the above step we still end up with multiple chains which
  represent sequential control flow chunks. But they are not yet suitable for
  code layout as we need to place *all* blocks into a single sequence.

  In this step we combine chains result from the above step via these steps:

  *)  Look at the ranked list of *all* edges, including calls/jumps across info tables
      and the like.

  *)  Look at each edge and

    +) Given an edge (A -&gt; B) try to find two chains for which
      * Block A is at the end of one chain
      * Block B is at the front of the other chain.
    +) If we find such a chain we &quot;fuse&quot; them into a single chain, remove the
       edge from working set and continue.
    +) If we can't find such chains we skip the edge and continue.

  -----------------------------------------------------------------------------
     3) Place indirect successors (neighbours) after each other
  -----------------------------------------------------------------------------

  We might have chains [A,B,C,X],[E] in a CFG of the sort:

    A ---&gt; B ---&gt; C --------&gt; X(exit)
                   \- -&gt;E- -/

  While E does not follow X it's still beneficial to place them near each other.
  This can be advantageous if eg C,X,E will end up in the same cache line.

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ~~~ Note [Triangle Control Flow]
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  Checking if an argument is already evaluated leads to a somewhat
  special case  which looks like this:

    A:
        if (R1 &amp; 7 != 0) goto Leval; else goto Lwork;
    Leval: // global
        call (I64[R1])(R1) returns to Lwork, args: 8, res: 8, upd: 8;
    Lwork: // global
        ...

        A
        |\
        | Leval
        |/ - (This edge can be missing because of optimizations)
        Lwork

  Once we hit the metal the call instruction is just 2-3 bytes large
  depending on the register used. So we lay out the assembly like this:

        movq %rbx,%rax
        andl $7,%eax
        cmpq $1,%rax
        jne Lwork
    Leval:
        jmp *(%rbx) # encoded in 2-3 bytes.
    &lt;info table&gt;
    Lwork:
        ...

  We could explicitly check for this control flow pattern.

  This is advantageous because:
  * It's optimal if the argument isn't evaluated.
  * If it's evaluated we only have the extra cost of jumping over
    the 2-3 bytes for the call.
  * Guarantees the smaller encoding for the conditional jump.

  However given that Lwork usually has an info table we
  penalize this edge. So Leval should get placed first
  either way and things work out for the best.

  Optimizing for the evaluated case instead would penalize
  the other code path. It adds an jump as we can't fall through
  to Lwork because of the info table.
  Assuming that Lwork is large the chance that the &quot;call&quot; ends up
  in the same cache line is also fairly small.

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ~~~ Note [Layout relevant edge weights]
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  The input to the chain based code layout algorithm is a CFG
  with edges annotated with their frequency. The frequency
  of traversal corresponds quite well to the cost of not placing
  the connected blocks next to each other.

  However even if having the same frequency certain edges are
  inherently more or less relevant to code layout.

  In particular:

  * Edges which cross an info table are less relevant than others.

    If we place the blocks across this edge next to each other
    they are still separated by the info table which negates
    much of the benefit. It makes it less likely both blocks
    will share a cache line reducing the benefits from locality.
    But it also prevents us from eliminating jump instructions.

  * Conditional branches and switches are slightly less relevant.

    We can completely remove unconditional jumps by placing them
    next to each other. This is not true for conditional branch edges.
    We apply a small modifier to them to ensure edges for which we can
    eliminate the overhead completely are considered first. See also #18053.

  * Edges constituted by a call are ignored.

    Considering these hardly helped with performance and ignoring
    them helps quite a bit to improve compiler performance.

  So we perform a preprocessing step where we apply a multiplicator
  to these kinds of edges.

  -}</span><span>
</span><span id="line-281"></span><span>
</span><span id="line-282"></span><span>
</span><span id="line-283"></span><span class="hs-comment">-- | Look at X number of blocks in two chains to determine</span><span>
</span><span id="line-284"></span><span class="hs-comment">--   if they are &quot;neighbours&quot;.</span><span>
</span><span id="line-285"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#neighbourOverlapp"><span class="hs-identifier hs-type">neighbourOverlapp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-286"></span><span id="neighbourOverlapp"><span class="annot"><span class="annottext">neighbourOverlapp :: Int
</span><a href="GHC.CmmToAsm.BlockLayout.html#neighbourOverlapp"><span class="hs-identifier hs-var hs-var">neighbourOverlapp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span>
</span><span id="line-287"></span><span>
</span><span id="line-288"></span><span class="hs-comment">-- | Maps blocks near the end of a chain to it's chain AND</span><span>
</span><span id="line-289"></span><span class="hs-comment">-- the other blocks near the end.</span><span>
</span><span id="line-290"></span><span class="hs-comment">-- [A,B,C,D,E] Gives entries like (B -&gt; ([A,B], [A,B,C,D,E]))</span><span>
</span><span id="line-291"></span><span class="hs-comment">-- where [A,B] are blocks in the end region of a chain.</span><span>
</span><span id="line-292"></span><span class="hs-comment">-- This is cheaper then recomputing the ends multiple times.</span><span>
</span><span id="line-293"></span><span class="hs-keyword">type</span><span> </span><span id="FrontierMap"><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#FrontierMap"><span class="hs-identifier hs-var">FrontierMap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-294"></span><span>
</span><span id="line-295"></span><span class="hs-comment">-- | A non empty ordered sequence of basic blocks.</span><span>
</span><span id="line-296"></span><span class="hs-comment">--   It is suitable for serialization in this order.</span><span>
</span><span id="line-297"></span><span class="hs-comment">--</span><span>
</span><span id="line-298"></span><span class="hs-comment">--   We use OrdList instead of [] to allow fast append on both sides</span><span>
</span><span id="line-299"></span><span class="hs-comment">--   when combining chains.</span><span>
</span><span id="line-300"></span><span class="hs-keyword">newtype</span><span> </span><span id="BlockChain"><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-var">BlockChain</span></a></span></span><span>
</span><span id="line-301"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="BlockChain"><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-var">BlockChain</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="chainBlocks"><span class="annot"><span class="annottext">BlockChain -&gt; OrdList BlockId
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainBlocks"><span class="hs-identifier hs-var hs-var">chainBlocks</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.OrdList.html#OrdList"><span class="hs-identifier hs-type">OrdList</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-302"></span><span>
</span><span id="line-303"></span><span class="hs-comment">-- All chains are constructed the same way so comparison</span><span>
</span><span id="line-304"></span><span class="hs-comment">-- including structure is faster.</span><span>
</span><span id="line-305"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681042239"><span class="annot"><span class="hs-identifier hs-type">Eq</span></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-306"></span><span>    </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042236"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042236"><span class="hs-identifier hs-var">b1</span></a></span></span><span> </span><span id="local-6989586621681042235"><span class="annot"><span class="annottext">== :: BlockChain -&gt; BlockChain -&gt; Bool
</span><span class="hs-operator hs-var hs-var hs-var hs-var">==</span></span></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042234"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042234"><span class="hs-identifier hs-var">b2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; OrdList BlockId -&gt; Bool
forall a. Eq a =&gt; OrdList a -&gt; OrdList a -&gt; Bool
</span><a href="GHC.Data.OrdList.html#strictlyEqOL"><span class="hs-identifier hs-var">strictlyEqOL</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042236"><span class="hs-identifier hs-var">b1</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042234"><span class="hs-identifier hs-var">b2</span></a></span><span>
</span><span id="line-307"></span><span>
</span><span id="line-308"></span><span class="hs-comment">-- Useful for things like sets and debugging purposes, sorts by blocks</span><span>
</span><span id="line-309"></span><span class="hs-comment">-- in the chain.</span><span>
</span><span id="line-310"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681042218"><span id="local-6989586621681042220"><span id="local-6989586621681042222"><span id="local-6989586621681042224"><span id="local-6989586621681042226"><span id="local-6989586621681042228"><span class="annot"><span class="hs-identifier hs-type">Ord</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">)</span></span></span></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-311"></span><span>   </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042209"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042209"><span class="hs-identifier hs-var">lbls1</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681042208"><span class="annot"><span class="annottext">compare :: BlockChain -&gt; BlockChain -&gt; Ordering
</span><span class="hs-operator hs-var hs-var hs-var hs-var">`compare`</span></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042206"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042206"><span class="hs-identifier hs-var">lbls2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-312"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">toList</span><span> </span><span class="hs-identifier">lbls1</span><span> </span><span class="hs-operator">/=</span><span> </span><span class="hs-identifier">toList</span><span> </span><span class="hs-identifier">lbls2</span><span> </span><span class="hs-operator">||</span><span> </span><span class="hs-identifier">lbls1</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">strictlyEqOL</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">lbls2</span><span class="hs-special">)</span><span>
</span><span id="line-313"></span><span>         </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; OrdList BlockId -&gt; Ordering
forall a. Ord a =&gt; OrdList a -&gt; OrdList a -&gt; Ordering
</span><a href="GHC.Data.OrdList.html#strictlyOrdOL"><span class="hs-identifier hs-var">strictlyOrdOL</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042209"><span class="hs-identifier hs-var">lbls1</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042206"><span class="hs-identifier hs-var">lbls2</span></a></span><span>
</span><span id="line-314"></span><span>
</span><span id="line-315"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681042196"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-316"></span><span>    </span><span id="local-6989586621681042193"><span class="annot"><span class="annottext">ppr :: BlockChain -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042191"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042191"><span class="hs-identifier hs-var">blks</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-317"></span><span>        </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Chain:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OrdList BlockId -&gt; [BlockId]
forall a. OrdList a -&gt; [a]
</span><a href="GHC.Data.OrdList.html#fromOL"><span class="hs-identifier hs-var">fromOL</span></a></span><span> </span><span class="annot"><span class="annottext">(OrdList BlockId -&gt; [BlockId]) -&gt; OrdList BlockId -&gt; [BlockId]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042191"><span class="hs-identifier hs-var">blks</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-318"></span><span>
</span><span id="line-319"></span><span id="local-6989586621681042511"><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#chainFoldl"><span class="hs-identifier hs-type">chainFoldl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621681042511"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681042511"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681042511"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681042511"><span class="hs-identifier hs-type">b</span></a></span></span><span>
</span><span id="line-320"></span><span id="chainFoldl"><span class="annot"><span class="annottext">chainFoldl :: forall b. (b -&gt; BlockId -&gt; b) -&gt; b -&gt; BlockChain -&gt; b
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainFoldl"><span class="hs-identifier hs-var hs-var">chainFoldl</span></a></span></span><span> </span><span id="local-6989586621681042184"><span class="annot"><span class="annottext">b -&gt; BlockId -&gt; b
</span><a href="#local-6989586621681042184"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621681042183"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681042183"><span class="hs-identifier hs-var">z</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042182"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042182"><span class="hs-identifier hs-var">blocks</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(b -&gt; BlockId -&gt; b) -&gt; b -&gt; OrdList BlockId -&gt; b
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">b -&gt; BlockId -&gt; b
</span><a href="#local-6989586621681042184"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681042183"><span class="hs-identifier hs-var">z</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042182"><span class="hs-identifier hs-var">blocks</span></a></span><span>
</span><span id="line-321"></span><span>
</span><span id="line-322"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#noDups"><span class="hs-identifier hs-type">noDups</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-323"></span><span id="noDups"><span class="annot"><span class="annottext">noDups :: [BlockChain] -&gt; Bool
</span><a href="GHC.CmmToAsm.BlockLayout.html#noDups"><span class="hs-identifier hs-var hs-var">noDups</span></a></span></span><span> </span><span id="local-6989586621681042179"><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681042179"><span class="hs-identifier hs-var">chains</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-324"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681042178"><span class="annot"><span class="annottext">chainBlocks :: [BlockId]
</span><a href="#local-6989586621681042178"><span class="hs-identifier hs-var hs-var">chainBlocks</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(BlockChain -&gt; [BlockId]) -&gt; [BlockChain] -&gt; [BlockId]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainToBlocks"><span class="hs-identifier hs-var">chainToBlocks</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681042179"><span class="hs-identifier hs-var">chains</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-325"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681042175"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042175"><span class="hs-identifier hs-var">_blocks</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681042174"><span class="annot"><span class="annottext">[NonEmpty BlockId]
</span><a href="#local-6989586621681042174"><span class="hs-identifier hs-var">dups</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(BlockId -&gt; BlockId -&gt; Ordering)
-&gt; [BlockId] -&gt; ([BlockId], [NonEmpty BlockId])
forall a. (a -&gt; a -&gt; Ordering) -&gt; [a] -&gt; ([a], [NonEmpty a])
</span><a href="GHC.Data.List.SetOps.html#removeDups"><span class="hs-identifier hs-var">removeDups</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; BlockId -&gt; Ordering
forall a. Ord a =&gt; a -&gt; a -&gt; Ordering
</span><span class="hs-identifier hs-var">compare</span></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042178"><span class="hs-identifier hs-var">chainBlocks</span></a></span><span>
</span><span id="line-326"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[NonEmpty BlockId] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[NonEmpty BlockId]
</span><a href="#local-6989586621681042174"><span class="hs-identifier hs-var">dups</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-327"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; Bool -&gt; Bool
forall a. String -&gt; SDoc -&gt; a -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprTrace"><span class="hs-identifier hs-var">pprTrace</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Duplicates:&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[[BlockId]] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(NonEmpty BlockId -&gt; [BlockId])
-&gt; [NonEmpty BlockId] -&gt; [[BlockId]]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">NonEmpty BlockId -&gt; [BlockId]
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#toList"><span class="hs-identifier hs-var">toList</span></a></span><span> </span><span class="annot"><span class="annottext">[NonEmpty BlockId]
</span><a href="#local-6989586621681042174"><span class="hs-identifier hs-var">dups</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;chains&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockChain] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681042179"><span class="hs-identifier hs-var">chains</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-328"></span><span>
</span><span id="line-329"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#inFront"><span class="hs-identifier hs-type">inFront</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-330"></span><span id="inFront"><span class="annot"><span class="annottext">inFront :: BlockId -&gt; BlockChain -&gt; Bool
</span><a href="GHC.CmmToAsm.BlockLayout.html#inFront"><span class="hs-identifier hs-var hs-var">inFront</span></a></span></span><span> </span><span id="local-6989586621681042169"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042169"><span class="hs-identifier hs-var">bid</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042168"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042168"><span class="hs-identifier hs-var">seq</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-331"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; BlockId
forall a. OrdList a -&gt; a
</span><a href="GHC.Data.OrdList.html#headOL"><span class="hs-identifier hs-var">headOL</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042168"><span class="hs-identifier hs-var">seq</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; BlockId -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042169"><span class="hs-identifier hs-var">bid</span></a></span><span>
</span><span id="line-332"></span><span>
</span><span id="line-333"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#chainSingleton"><span class="hs-identifier hs-type">chainSingleton</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span>
</span><span id="line-334"></span><span id="chainSingleton"><span class="annot"><span class="annottext">chainSingleton :: BlockId -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainSingleton"><span class="hs-identifier hs-var hs-var">chainSingleton</span></a></span></span><span> </span><span id="local-6989586621681042165"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042165"><span class="hs-identifier hs-var">lbl</span></a></span></span><span>
</span><span id="line-335"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-var">BlockChain</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; OrdList BlockId
forall a. a -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#unitOL"><span class="hs-identifier hs-var">unitOL</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042165"><span class="hs-identifier hs-var">lbl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-336"></span><span>
</span><span id="line-337"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#chainFromList"><span class="hs-identifier hs-type">chainFromList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span>
</span><span id="line-338"></span><span id="chainFromList"><span class="annot"><span class="annottext">chainFromList :: [BlockId] -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainFromList"><span class="hs-identifier hs-var hs-var">chainFromList</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-var">BlockChain</span></a></span><span> </span><span class="annot"><span class="annottext">(OrdList BlockId -&gt; BlockChain)
-&gt; ([BlockId] -&gt; OrdList BlockId) -&gt; [BlockId] -&gt; BlockChain
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId] -&gt; OrdList BlockId
forall a. [a] -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#toOL"><span class="hs-identifier hs-var">toOL</span></a></span><span>
</span><span id="line-339"></span><span>
</span><span id="line-340"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#chainSnoc"><span class="hs-identifier hs-type">chainSnoc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span>
</span><span id="line-341"></span><span id="chainSnoc"><span class="annot"><span class="annottext">chainSnoc :: BlockChain -&gt; BlockId -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainSnoc"><span class="hs-identifier hs-var hs-var">chainSnoc</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042159"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042159"><span class="hs-identifier hs-var">blks</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681042158"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042158"><span class="hs-identifier hs-var">lbl</span></a></span></span><span>
</span><span id="line-342"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-var">BlockChain</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042159"><span class="hs-identifier hs-var">blks</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; BlockId -&gt; OrdList BlockId
forall a. OrdList a -&gt; a -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#snocOL"><span class="hs-operator hs-var">`snocOL`</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042158"><span class="hs-identifier hs-var">lbl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-343"></span><span>
</span><span id="line-344"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#chainCons"><span class="hs-identifier hs-type">chainCons</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span>
</span><span id="line-345"></span><span id="chainCons"><span class="annot"><span class="annottext">chainCons :: BlockId -&gt; BlockChain -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainCons"><span class="hs-identifier hs-var hs-var">chainCons</span></a></span></span><span> </span><span id="local-6989586621681042155"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042155"><span class="hs-identifier hs-var">lbl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042154"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042154"><span class="hs-identifier hs-var">blks</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-346"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-var">BlockChain</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042155"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; OrdList BlockId -&gt; OrdList BlockId
forall a. a -&gt; OrdList a -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#consOL"><span class="hs-operator hs-var">`consOL`</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042154"><span class="hs-identifier hs-var">blks</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-347"></span><span>
</span><span id="line-348"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#chainConcat"><span class="hs-identifier hs-type">chainConcat</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span>
</span><span id="line-349"></span><span id="chainConcat"><span class="annot"><span class="annottext">chainConcat :: BlockChain -&gt; BlockChain -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainConcat"><span class="hs-identifier hs-var hs-var">chainConcat</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042151"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042151"><span class="hs-identifier hs-var">blks1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042150"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042150"><span class="hs-identifier hs-var">blks2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-350"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-var">BlockChain</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042151"><span class="hs-identifier hs-var">blks1</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; OrdList BlockId -&gt; OrdList BlockId
forall a. OrdList a -&gt; OrdList a -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#appOL"><span class="hs-operator hs-var">`appOL`</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042150"><span class="hs-identifier hs-var">blks2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-351"></span><span>
</span><span id="line-352"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#chainToBlocks"><span class="hs-identifier hs-type">chainToBlocks</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-353"></span><span id="chainToBlocks"><span class="annot"><span class="annottext">chainToBlocks :: BlockChain -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainToBlocks"><span class="hs-identifier hs-var hs-var">chainToBlocks</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042148"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042148"><span class="hs-identifier hs-var">blks</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; [BlockId]
forall a. OrdList a -&gt; [a]
</span><a href="GHC.Data.OrdList.html#fromOL"><span class="hs-identifier hs-var">fromOL</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042148"><span class="hs-identifier hs-var">blks</span></a></span><span>
</span><span id="line-354"></span><span>
</span><span id="line-355"></span><span class="hs-comment">-- | Given the Chain A -&gt; B -&gt; C -&gt; D and we break at C</span><span>
</span><span id="line-356"></span><span class="hs-comment">--   we get the two Chains (A -&gt; B, C -&gt; D) as result.</span><span>
</span><span id="line-357"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#breakChainAt"><span class="hs-identifier hs-type">breakChainAt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span>
</span><span id="line-358"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-359"></span><span id="breakChainAt"><span class="annot"><span class="annottext">breakChainAt :: BlockId -&gt; BlockChain -&gt; (BlockChain, BlockChain)
</span><a href="GHC.CmmToAsm.BlockLayout.html#breakChainAt"><span class="hs-identifier hs-var hs-var">breakChainAt</span></a></span></span><span> </span><span id="local-6989586621681042146"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042146"><span class="hs-identifier hs-var">bid</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042145"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042145"><span class="hs-identifier hs-var">blks</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-360"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042146"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; BlockId -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">[BlockId] -&gt; BlockId
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042143"><span class="hs-identifier hs-var">rblks</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-361"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (BlockChain, BlockChain)
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Block not in chain&quot;</span></span><span>
</span><span id="line-362"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-363"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OrdList BlockId -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-var">BlockChain</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockId] -&gt; OrdList BlockId
forall a. [a] -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#toOL"><span class="hs-identifier hs-var">toOL</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042141"><span class="hs-identifier hs-var">lblks</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-364"></span><span>       </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-var">BlockChain</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockId] -&gt; OrdList BlockId
forall a. [a] -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#toOL"><span class="hs-identifier hs-var">toOL</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042143"><span class="hs-identifier hs-var">rblks</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-365"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-366"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681042141"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042141"><span class="hs-identifier hs-var">lblks</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681042143"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042143"><span class="hs-identifier hs-var">rblks</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(BlockId -&gt; Bool) -&gt; [BlockId] -&gt; ([BlockId], [BlockId])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/GHC.List.html#break"><span class="hs-identifier hs-var">break</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681042139"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042139"><span class="hs-identifier hs-var">lbl</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042139"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; BlockId -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042146"><span class="hs-identifier hs-var">bid</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OrdList BlockId -&gt; [BlockId]
forall a. OrdList a -&gt; [a]
</span><a href="GHC.Data.OrdList.html#fromOL"><span class="hs-identifier hs-var">fromOL</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042145"><span class="hs-identifier hs-var">blks</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-367"></span><span>
</span><span id="line-368"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#takeR"><span class="hs-identifier hs-type">takeR</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-369"></span><span id="takeR"><span class="annot"><span class="annottext">takeR :: Int -&gt; BlockChain -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.BlockLayout.html#takeR"><span class="hs-identifier hs-var hs-var">takeR</span></a></span></span><span> </span><span id="local-6989586621681042137"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681042137"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042136"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042136"><span class="hs-identifier hs-var">blks</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-370"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; [BlockId] -&gt; [BlockId]
forall a. Int -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#take"><span class="hs-identifier hs-var">take</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681042137"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">([BlockId] -&gt; [BlockId])
-&gt; (OrdList BlockId -&gt; [BlockId]) -&gt; OrdList BlockId -&gt; [BlockId]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; [BlockId]
forall a. OrdList a -&gt; [a]
</span><a href="GHC.Data.OrdList.html#fromOLReverse"><span class="hs-identifier hs-var">fromOLReverse</span></a></span><span> </span><span class="annot"><span class="annottext">(OrdList BlockId -&gt; [BlockId]) -&gt; OrdList BlockId -&gt; [BlockId]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042136"><span class="hs-identifier hs-var">blks</span></a></span><span>
</span><span id="line-371"></span><span>
</span><span id="line-372"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#takeL"><span class="hs-identifier hs-type">takeL</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-373"></span><span id="takeL"><span class="annot"><span class="annottext">takeL :: Int -&gt; BlockChain -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.BlockLayout.html#takeL"><span class="hs-identifier hs-var hs-var">takeL</span></a></span></span><span> </span><span id="local-6989586621681042132"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681042132"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span id="local-6989586621681042131"><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042131"><span class="hs-identifier hs-var">blks</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-374"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; [BlockId] -&gt; [BlockId]
forall a. Int -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#take"><span class="hs-identifier hs-var">take</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681042132"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">([BlockId] -&gt; [BlockId])
-&gt; (OrdList BlockId -&gt; [BlockId]) -&gt; OrdList BlockId -&gt; [BlockId]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; [BlockId]
forall a. OrdList a -&gt; [a]
</span><a href="GHC.Data.OrdList.html#fromOL"><span class="hs-identifier hs-var">fromOL</span></a></span><span> </span><span class="annot"><span class="annottext">(OrdList BlockId -&gt; [BlockId]) -&gt; OrdList BlockId -&gt; [BlockId]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId
</span><a href="#local-6989586621681042131"><span class="hs-identifier hs-var">blks</span></a></span><span>
</span><span id="line-375"></span><span>
</span><span id="line-376"></span><span class="hs-comment">-- Note [Combining neighborhood chains]</span><span>
</span><span id="line-377"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-378"></span><span>
</span><span id="line-379"></span><span class="hs-comment">-- See also Note [Chain based CFG serialization]</span><span>
</span><span id="line-380"></span><span class="hs-comment">-- We have the chains (A-B-C-D) and (E-F) and an Edge C-&gt;E.</span><span>
</span><span id="line-381"></span><span class="hs-comment">--</span><span>
</span><span id="line-382"></span><span class="hs-comment">-- While placing the latter after the former doesn't result in sequential</span><span>
</span><span id="line-383"></span><span class="hs-comment">-- control flow it is still beneficial. As block C and E might end</span><span>
</span><span id="line-384"></span><span class="hs-comment">-- up in the same cache line.</span><span>
</span><span id="line-385"></span><span class="hs-comment">--</span><span>
</span><span id="line-386"></span><span class="hs-comment">-- So we place these chains next to each other even if we can't fuse them.</span><span>
</span><span id="line-387"></span><span class="hs-comment">--</span><span>
</span><span id="line-388"></span><span class="hs-comment">--   A -&gt; B -&gt; C -&gt; D</span><span>
</span><span id="line-389"></span><span class="hs-comment">--             v</span><span>
</span><span id="line-390"></span><span class="hs-comment">--             - -&gt; E -&gt; F ...</span><span>
</span><span id="line-391"></span><span class="hs-comment">--</span><span>
</span><span id="line-392"></span><span class="hs-comment">-- A simple heuristic to chose which chains we want to combine:</span><span>
</span><span id="line-393"></span><span class="hs-comment">--   * Process edges in descending priority.</span><span>
</span><span id="line-394"></span><span class="hs-comment">--   * Check if there is a edge near the end of one chain which goes</span><span>
</span><span id="line-395"></span><span class="hs-comment">--     to a block near the start of another edge.</span><span>
</span><span id="line-396"></span><span class="hs-comment">--</span><span>
</span><span id="line-397"></span><span class="hs-comment">-- While we could take into account the space between the two blocks which</span><span>
</span><span id="line-398"></span><span class="hs-comment">-- share an edge this blows up compile times quite a bit. It requires</span><span>
</span><span id="line-399"></span><span class="hs-comment">-- us to find all edges between two chains, check the distance for all edges,</span><span>
</span><span id="line-400"></span><span class="hs-comment">-- rank them based on the distance and only then we can select two chains</span><span>
</span><span id="line-401"></span><span class="hs-comment">-- to combine. Which would add a lot of complexity for little gain.</span><span>
</span><span id="line-402"></span><span class="hs-comment">--</span><span>
</span><span id="line-403"></span><span class="hs-comment">-- So instead we just rank by the strength of the edge and use the first pair we</span><span>
</span><span id="line-404"></span><span class="hs-comment">-- find.</span><span>
</span><span id="line-405"></span><span>
</span><span id="line-406"></span><span class="hs-comment">-- | For a given list of chains and edges try to combine chains with strong</span><span>
</span><span id="line-407"></span><span class="hs-comment">--   edges between them.</span><span>
</span><span id="line-408"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#combineNeighbourhood"><span class="hs-identifier hs-type">combineNeighbourhood</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- ^ Edges to consider</span><span>
</span><span id="line-409"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- ^ Current chains of blocks</span><span>
</span><span id="line-410"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.Internal.html#Set"><span class="hs-identifier hs-type">Set.Set</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-411"></span><span>                      </span><span class="hs-comment">-- ^ Resulting list of block chains, and a set of edges which</span><span>
</span><span id="line-412"></span><span>                      </span><span class="hs-comment">-- were used to fuse chains and as such no longer need to be</span><span>
</span><span id="line-413"></span><span>                      </span><span class="hs-comment">-- considered.</span><span>
</span><span id="line-414"></span><span id="combineNeighbourhood"><span class="annot"><span class="annottext">combineNeighbourhood :: [CfgEdge] -&gt; [BlockChain] -&gt; ([BlockChain], Set (BlockId, BlockId))
</span><a href="GHC.CmmToAsm.BlockLayout.html#combineNeighbourhood"><span class="hs-identifier hs-var hs-var">combineNeighbourhood</span></a></span></span><span> </span><span id="local-6989586621681042129"><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681042129"><span class="hs-identifier hs-var">edges</span></a></span></span><span> </span><span id="local-6989586621681042128"><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681042128"><span class="hs-identifier hs-var">chains</span></a></span></span><span>
</span><span id="line-415"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTraceIt &quot;Neighbours&quot; $</span><span>
</span><span id="line-416"></span><span>    </span><span class="hs-comment">--   pprTrace &quot;combineNeighbours&quot; (ppr edges) $</span><span>
</span><span id="line-417"></span><span>      </span><span class="annot"><span class="annottext">[CfgEdge]
-&gt; FrontierMap
-&gt; FrontierMap
-&gt; Set (BlockId, BlockId)
-&gt; ([BlockChain], Set (BlockId, BlockId))
</span><a href="#local-6989586621681042127"><span class="hs-identifier hs-var">applyEdges</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681042129"><span class="hs-identifier hs-var">edges</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042126"><span class="hs-identifier hs-var">endFrontier</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042125"><span class="hs-identifier hs-var">startFrontier</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
forall a. Set a
</span><a href="../../containers/src/Data.Set.Internal.html#empty"><span class="hs-identifier hs-var">Set.empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-418"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-419"></span><span>        </span><span class="hs-comment">--Build maps from chain ends to chains</span><span>
</span><span id="line-420"></span><span>        </span><span class="annot"><a href="#local-6989586621681042126"><span class="hs-identifier hs-type">endFrontier</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621681042125"><span class="hs-identifier hs-type">startFrontier</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#FrontierMap"><span class="hs-identifier hs-type">FrontierMap</span></a></span><span>
</span><span id="line-421"></span><span>        </span><span id="local-6989586621681042126"><span class="annot"><span class="annottext">endFrontier :: FrontierMap
</span><a href="#local-6989586621681042126"><span class="hs-identifier hs-var hs-var">endFrontier</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-422"></span><span>            </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, ([BlockId], BlockChain))] -&gt; FrontierMap
forall (map :: * -&gt; *) a. IsMap map =&gt; [(KeyOf map, a)] -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFromList"><span class="hs-identifier hs-var">mapFromList</span></a></span><span> </span><span class="annot"><span class="annottext">([(KeyOf LabelMap, ([BlockId], BlockChain))] -&gt; FrontierMap)
-&gt; [(KeyOf LabelMap, ([BlockId], BlockChain))] -&gt; FrontierMap
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(BlockChain -&gt; [(BlockId, ([BlockId], BlockChain))])
-&gt; [BlockChain] -&gt; [(BlockId, ([BlockId], BlockChain))]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681042122"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042122"><span class="hs-identifier hs-var">chain</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-423"></span><span>                                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681042121"><span class="annot"><span class="annottext">ends :: [BlockId]
</span><a href="#local-6989586621681042121"><span class="hs-identifier hs-var hs-var">ends</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; [BlockId]
</span><a href="#local-6989586621681042120"><span class="hs-identifier hs-var">getEnds</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042122"><span class="hs-identifier hs-var">chain</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-424"></span><span>                                    </span><span id="local-6989586621681042119"><span class="annot"><span class="annottext">entry :: ([BlockId], BlockChain)
</span><a href="#local-6989586621681042119"><span class="hs-identifier hs-var hs-var">entry</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042121"><span class="hs-identifier hs-var">ends</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042122"><span class="hs-identifier hs-var">chain</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-425"></span><span>                                </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">(BlockId -&gt; (BlockId, ([BlockId], BlockChain)))
-&gt; [BlockId] -&gt; [(BlockId, ([BlockId], BlockChain))]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681042118"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042118"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042118"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">([BlockId], BlockChain)
</span><a href="#local-6989586621681042119"><span class="hs-identifier hs-var">entry</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042121"><span class="hs-identifier hs-var">ends</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681042128"><span class="hs-identifier hs-var">chains</span></a></span><span>
</span><span id="line-426"></span><span>        </span><span id="local-6989586621681042125"><span class="annot"><span class="annottext">startFrontier :: FrontierMap
</span><a href="#local-6989586621681042125"><span class="hs-identifier hs-var hs-var">startFrontier</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-427"></span><span>            </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, ([BlockId], BlockChain))] -&gt; FrontierMap
forall (map :: * -&gt; *) a. IsMap map =&gt; [(KeyOf map, a)] -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFromList"><span class="hs-identifier hs-var">mapFromList</span></a></span><span> </span><span class="annot"><span class="annottext">([(KeyOf LabelMap, ([BlockId], BlockChain))] -&gt; FrontierMap)
-&gt; [(KeyOf LabelMap, ([BlockId], BlockChain))] -&gt; FrontierMap
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(BlockChain -&gt; [(BlockId, ([BlockId], BlockChain))])
-&gt; [BlockChain] -&gt; [(BlockId, ([BlockId], BlockChain))]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681042117"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042117"><span class="hs-identifier hs-var">chain</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-428"></span><span>                                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681042116"><span class="annot"><span class="annottext">front :: [BlockId]
</span><a href="#local-6989586621681042116"><span class="hs-identifier hs-var hs-var">front</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; [BlockId]
</span><a href="#local-6989586621681042115"><span class="hs-identifier hs-var">getFronts</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042117"><span class="hs-identifier hs-var">chain</span></a></span><span>
</span><span id="line-429"></span><span>                                    </span><span id="local-6989586621681042114"><span class="annot"><span class="annottext">entry :: ([BlockId], BlockChain)
</span><a href="#local-6989586621681042114"><span class="hs-identifier hs-var hs-var">entry</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042116"><span class="hs-identifier hs-var">front</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042117"><span class="hs-identifier hs-var">chain</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-430"></span><span>                                </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">(BlockId -&gt; (BlockId, ([BlockId], BlockChain)))
-&gt; [BlockId] -&gt; [(BlockId, ([BlockId], BlockChain))]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681042113"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042113"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042113"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">([BlockId], BlockChain)
</span><a href="#local-6989586621681042114"><span class="hs-identifier hs-var">entry</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042116"><span class="hs-identifier hs-var">front</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681042128"><span class="hs-identifier hs-var">chains</span></a></span><span>
</span><span id="line-431"></span><span>        </span><span class="annot"><a href="#local-6989586621681042127"><span class="hs-identifier hs-type">applyEdges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#FrontierMap"><span class="hs-identifier hs-type">FrontierMap</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#FrontierMap"><span class="hs-identifier hs-type">FrontierMap</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.Internal.html#Set"><span class="hs-identifier hs-type">Set.Set</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-432"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.Internal.html#Set"><span class="hs-identifier hs-type">Set.Set</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-433"></span><span>        </span><span id="local-6989586621681042127"><span class="annot"><span class="annottext">applyEdges :: [CfgEdge]
-&gt; FrontierMap
-&gt; FrontierMap
-&gt; Set (BlockId, BlockId)
-&gt; ([BlockChain], Set (BlockId, BlockId))
</span><a href="#local-6989586621681042127"><span class="hs-identifier hs-var hs-var">applyEdges</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621681042112"><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042112"><span class="hs-identifier hs-var">chainEnds</span></a></span></span><span> </span><span id="local-6989586621681042111"><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042111"><span class="hs-identifier hs-var">_chainFronts</span></a></span></span><span> </span><span id="local-6989586621681042110"><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681042110"><span class="hs-identifier hs-var">combined</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-434"></span><span>            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockChain] -&gt; [BlockChain]
forall a. Ord a =&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#ordNub"><span class="hs-identifier hs-var">ordNub</span></a></span><span> </span><span class="annot"><span class="annottext">([BlockChain] -&gt; [BlockChain]) -&gt; [BlockChain] -&gt; [BlockChain]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(([BlockId], BlockChain) -&gt; BlockChain)
-&gt; [([BlockId], BlockChain)] -&gt; [BlockChain]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">([BlockId], BlockChain) -&gt; BlockChain
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">([([BlockId], BlockChain)] -&gt; [BlockChain])
-&gt; [([BlockId], BlockChain)] -&gt; [BlockChain]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap -&gt; [([BlockId], BlockChain)]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [a]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapElems"><span class="hs-identifier hs-var">mapElems</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042112"><span class="hs-identifier hs-var">chainEnds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681042110"><span class="hs-identifier hs-var">combined</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-435"></span><span>        </span><span class="annot"><a href="#local-6989586621681042127"><span class="hs-identifier hs-var">applyEdges</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span id="local-6989586621681042106"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042106"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681042105"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042105"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621681042104"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681042104"><span class="hs-identifier hs-var">_w</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681042103"><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681042103"><span class="hs-identifier hs-var">edges</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681042102"><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042102"><span class="hs-identifier hs-var">chainEnds</span></a></span></span><span> </span><span id="local-6989586621681042101"><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042101"><span class="hs-identifier hs-var">chainFronts</span></a></span></span><span> </span><span id="local-6989586621681042100"><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681042100"><span class="hs-identifier hs-var">combined</span></a></span></span><span>
</span><span id="line-436"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681042099"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042099"><span class="hs-identifier hs-var">c1_e</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681042098"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042098"><span class="hs-identifier hs-var">c1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; FrontierMap -&gt; Maybe ([BlockId], BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681042106"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042102"><span class="hs-identifier hs-var">chainEnds</span></a></span><span>
</span><span id="line-437"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681042096"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042096"><span class="hs-identifier hs-var">c2_f</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681042095"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042095"><span class="hs-identifier hs-var">c2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; FrontierMap -&gt; Maybe ([BlockId], BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681042105"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042101"><span class="hs-identifier hs-var">chainFronts</span></a></span><span>
</span><span id="line-438"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042098"><span class="hs-identifier hs-var">c1</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; BlockChain -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042095"><span class="hs-identifier hs-var">c2</span></a></span><span> </span><span class="hs-comment">-- Avoid trying to concat a chain with itself.</span><span>
</span><span id="line-439"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681042094"><span class="annot"><span class="annottext">newChain :: BlockChain
</span><a href="#local-6989586621681042094"><span class="hs-identifier hs-var hs-var">newChain</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; BlockChain -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainConcat"><span class="hs-identifier hs-var">chainConcat</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042098"><span class="hs-identifier hs-var">c1</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042095"><span class="hs-identifier hs-var">c2</span></a></span><span>
</span><span id="line-440"></span><span>                  </span><span id="local-6989586621681042093"><span class="annot"><span class="annottext">newChainFrontier :: [BlockId]
</span><a href="#local-6989586621681042093"><span class="hs-identifier hs-var hs-var">newChainFrontier</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; [BlockId]
</span><a href="#local-6989586621681042115"><span class="hs-identifier hs-var">getFronts</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042094"><span class="hs-identifier hs-var">newChain</span></a></span><span>
</span><span id="line-441"></span><span>                  </span><span id="local-6989586621681042092"><span class="annot"><span class="annottext">newChainEnds :: [BlockId]
</span><a href="#local-6989586621681042092"><span class="hs-identifier hs-var hs-var">newChainEnds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; [BlockId]
</span><a href="#local-6989586621681042120"><span class="hs-identifier hs-var">getEnds</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042094"><span class="hs-identifier hs-var">newChain</span></a></span><span>
</span><span id="line-442"></span><span>                  </span><span class="annot"><a href="#local-6989586621681042091"><span class="hs-identifier hs-type">newFronts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#FrontierMap"><span class="hs-identifier hs-type">FrontierMap</span></a></span><span>
</span><span id="line-443"></span><span>                  </span><span id="local-6989586621681042091"><span class="annot"><span class="annottext">newFronts :: FrontierMap
</span><a href="#local-6989586621681042091"><span class="hs-identifier hs-var hs-var">newFronts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-444"></span><span>                    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681042090"><span class="annot"><span class="annottext">withoutOld :: FrontierMap
</span><a href="#local-6989586621681042090"><span class="hs-identifier hs-var hs-var">withoutOld</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-445"></span><span>                            </span><span class="annot"><span class="annottext">(FrontierMap -&gt; BlockId -&gt; FrontierMap)
-&gt; FrontierMap -&gt; [BlockId] -&gt; FrontierMap
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681042089"><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042089"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681042088"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042088"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; FrontierMap -&gt; FrontierMap
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapDelete"><span class="hs-identifier hs-var">mapDelete</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681042088"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042089"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#FrontierMap"><span class="hs-identifier hs-type">FrontierMap</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042101"><span class="hs-identifier hs-var">chainFronts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042096"><span class="hs-identifier hs-var">c2_f</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId] -&gt; [BlockId] -&gt; [BlockId]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; [BlockId]
</span><a href="#local-6989586621681042115"><span class="hs-identifier hs-var">getFronts</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042098"><span class="hs-identifier hs-var">c1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-446"></span><span>                        </span><span id="local-6989586621681042086"><span class="annot"><span class="annottext">entry :: ([BlockId], BlockChain)
</span><a href="#local-6989586621681042086"><span class="hs-identifier hs-var hs-var">entry</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-447"></span><span>                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042093"><span class="hs-identifier hs-var">newChainFrontier</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042094"><span class="hs-identifier hs-var">newChain</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">--let bound to ensure sharing</span><span>
</span><span id="line-448"></span><span>                    </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">(FrontierMap -&gt; BlockId -&gt; FrontierMap)
-&gt; FrontierMap -&gt; [BlockId] -&gt; FrontierMap
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681042085"><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042085"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681042084"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042084"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; ([BlockId], BlockChain) -&gt; FrontierMap -&gt; FrontierMap
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681042084"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">([BlockId], BlockChain)
</span><a href="#local-6989586621681042086"><span class="hs-identifier hs-var">entry</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042085"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-449"></span><span>                              </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042090"><span class="hs-identifier hs-var">withoutOld</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042093"><span class="hs-identifier hs-var">newChainFrontier</span></a></span><span>
</span><span id="line-450"></span><span>
</span><span id="line-451"></span><span>                  </span><span id="local-6989586621681042082"><span class="annot"><span class="annottext">newEnds :: FrontierMap
</span><a href="#local-6989586621681042082"><span class="hs-identifier hs-var hs-var">newEnds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-452"></span><span>                    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681042081"><span class="annot"><span class="annottext">withoutOld :: FrontierMap
</span><a href="#local-6989586621681042081"><span class="hs-identifier hs-var hs-var">withoutOld</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(FrontierMap -&gt; BlockId -&gt; FrontierMap)
-&gt; FrontierMap -&gt; [BlockId] -&gt; FrontierMap
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681042080"><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042080"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681042079"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042079"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; FrontierMap -&gt; FrontierMap
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapDelete"><span class="hs-identifier hs-var">mapDelete</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681042079"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042080"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042102"><span class="hs-identifier hs-var">chainEnds</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042099"><span class="hs-identifier hs-var">c1_e</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId] -&gt; [BlockId] -&gt; [BlockId]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; [BlockId]
</span><a href="#local-6989586621681042120"><span class="hs-identifier hs-var">getEnds</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042095"><span class="hs-identifier hs-var">c2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-453"></span><span>                        </span><span id="local-6989586621681042078"><span class="annot"><span class="annottext">entry :: ([BlockId], BlockChain)
</span><a href="#local-6989586621681042078"><span class="hs-identifier hs-var hs-var">entry</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042092"><span class="hs-identifier hs-var">newChainEnds</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042094"><span class="hs-identifier hs-var">newChain</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">--let bound to ensure sharing</span><span>
</span><span id="line-454"></span><span>                    </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">(FrontierMap -&gt; BlockId -&gt; FrontierMap)
-&gt; FrontierMap -&gt; [BlockId] -&gt; FrontierMap
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681042077"><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042077"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681042076"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042076"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; ([BlockId], BlockChain) -&gt; FrontierMap -&gt; FrontierMap
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681042076"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">([BlockId], BlockChain)
</span><a href="#local-6989586621681042078"><span class="hs-identifier hs-var">entry</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042077"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-455"></span><span>                              </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042081"><span class="hs-identifier hs-var">withoutOld</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681042092"><span class="hs-identifier hs-var">newChainEnds</span></a></span><span>
</span><span id="line-456"></span><span>              </span><span class="hs-keyword">in</span><span>
</span><span id="line-457"></span><span>                </span><span class="hs-comment">-- pprTrace &quot;ApplyEdges&quot;</span><span>
</span><span id="line-458"></span><span>                </span><span class="hs-comment">--  (text &quot;before&quot; $$</span><span>
</span><span id="line-459"></span><span>                </span><span class="hs-comment">--   text &quot;fronts&quot; &lt;+&gt; ppr chainFronts $$</span><span>
</span><span id="line-460"></span><span>                </span><span class="hs-comment">--   text &quot;ends&quot; &lt;+&gt; ppr chainEnds $$</span><span>
</span><span id="line-461"></span><span>
</span><span id="line-462"></span><span>                </span><span class="hs-comment">--   text &quot;various&quot; $$</span><span>
</span><span id="line-463"></span><span>                </span><span class="hs-comment">--   text &quot;newChain&quot; &lt;+&gt; ppr newChain $$</span><span>
</span><span id="line-464"></span><span>                </span><span class="hs-comment">--   text &quot;newChainFrontier&quot; &lt;+&gt; ppr newChainFrontier $$</span><span>
</span><span id="line-465"></span><span>                </span><span class="hs-comment">--   text &quot;newChainEnds&quot; &lt;+&gt; ppr newChainEnds $$</span><span>
</span><span id="line-466"></span><span>                </span><span class="hs-comment">--   text &quot;drop&quot; &lt;+&gt; ppr ((c2_f ++ getFronts c1) ++ (c1_e ++ getEnds c2)) $$</span><span>
</span><span id="line-467"></span><span>
</span><span id="line-468"></span><span>                </span><span class="hs-comment">--   text &quot;after&quot; $$</span><span>
</span><span id="line-469"></span><span>                </span><span class="hs-comment">--   text &quot;fronts&quot; &lt;+&gt; ppr newFronts $$</span><span>
</span><span id="line-470"></span><span>                </span><span class="hs-comment">--   text &quot;ends&quot; &lt;+&gt; ppr newEnds</span><span>
</span><span id="line-471"></span><span>                </span><span class="hs-comment">--   )</span><span>
</span><span id="line-472"></span><span>                 </span><span class="annot"><span class="annottext">[CfgEdge]
-&gt; FrontierMap
-&gt; FrontierMap
-&gt; Set (BlockId, BlockId)
-&gt; ([BlockChain], Set (BlockId, BlockId))
</span><a href="#local-6989586621681042127"><span class="hs-identifier hs-var">applyEdges</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681042103"><span class="hs-identifier hs-var">edges</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042082"><span class="hs-identifier hs-var">newEnds</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042091"><span class="hs-identifier hs-var">newFronts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(BlockId, BlockId)
-&gt; Set (BlockId, BlockId) -&gt; Set (BlockId, BlockId)
forall a. Ord a =&gt; a -&gt; Set a -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#insert"><span class="hs-identifier hs-var">Set.insert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042106"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042105"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681042100"><span class="hs-identifier hs-var">combined</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-473"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-474"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
-&gt; FrontierMap
-&gt; FrontierMap
-&gt; Set (BlockId, BlockId)
-&gt; ([BlockChain], Set (BlockId, BlockId))
</span><a href="#local-6989586621681042127"><span class="hs-identifier hs-var">applyEdges</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681042103"><span class="hs-identifier hs-var">edges</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042102"><span class="hs-identifier hs-var">chainEnds</span></a></span><span> </span><span class="annot"><span class="annottext">FrontierMap
</span><a href="#local-6989586621681042101"><span class="hs-identifier hs-var">chainFronts</span></a></span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681042100"><span class="hs-identifier hs-var">combined</span></a></span><span>
</span><span id="line-475"></span><span>         </span><span class="hs-keyword">where</span><span>
</span><span id="line-476"></span><span>
</span><span id="line-477"></span><span>        </span><span id="local-6989586621681042115"><span class="annot"><span class="annottext">getFronts :: BlockChain -&gt; [BlockId]
</span><a href="#local-6989586621681042115"><span class="hs-identifier hs-var hs-var">getFronts</span></a></span></span><span> </span><span id="local-6989586621681042074"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042074"><span class="hs-identifier hs-var">chain</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; BlockChain -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.BlockLayout.html#takeL"><span class="hs-identifier hs-var">takeL</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.CmmToAsm.BlockLayout.html#neighbourOverlapp"><span class="hs-identifier hs-var">neighbourOverlapp</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042074"><span class="hs-identifier hs-var">chain</span></a></span><span>
</span><span id="line-478"></span><span>        </span><span id="local-6989586621681042120"><span class="annot"><span class="annottext">getEnds :: BlockChain -&gt; [BlockId]
</span><a href="#local-6989586621681042120"><span class="hs-identifier hs-var hs-var">getEnds</span></a></span></span><span> </span><span id="local-6989586621681042073"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042073"><span class="hs-identifier hs-var">chain</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; BlockChain -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.BlockLayout.html#takeR"><span class="hs-identifier hs-var">takeR</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.CmmToAsm.BlockLayout.html#neighbourOverlapp"><span class="hs-identifier hs-var">neighbourOverlapp</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042073"><span class="hs-identifier hs-var">chain</span></a></span><span>
</span><span id="line-479"></span><span>
</span><span id="line-480"></span><span class="hs-comment">-- In the last stop we combine all chains into a single one.</span><span>
</span><span id="line-481"></span><span class="hs-comment">-- Trying to place chains with strong edges next to each other.</span><span>
</span><span id="line-482"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#mergeChains"><span class="hs-identifier hs-type">mergeChains</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-483"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-484"></span><span id="mergeChains"><span class="annot"><span class="annottext">mergeChains :: [CfgEdge] -&gt; [BlockChain] -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#mergeChains"><span class="hs-identifier hs-var hs-var">mergeChains</span></a></span></span><span> </span><span id="local-6989586621681042071"><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681042071"><span class="hs-identifier hs-var">edges</span></a></span></span><span> </span><span id="local-6989586621681042070"><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681042070"><span class="hs-identifier hs-var">chains</span></a></span></span><span>
</span><span id="line-485"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(forall s. ST s BlockChain) -&gt; BlockChain
forall a. (forall s. ST s a) -&gt; a
</span><a href="../../base/src/GHC.ST.html#runST"><span class="hs-identifier hs-var">runST</span></a></span><span> </span><span class="annot"><span class="annottext">((forall s. ST s BlockChain) -&gt; BlockChain)
-&gt; (forall s. ST s BlockChain) -&gt; BlockChain
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-486"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681042052"><span class="annot"><span class="annottext">addChain :: map (Point s BlockChain)
-&gt; BlockChain -&gt; ST s (map (Point s BlockChain))
</span><a href="#local-6989586621681042052"><span class="hs-identifier hs-var hs-var">addChain</span></a></span></span><span> </span><span id="local-6989586621681042051"><span class="annot"><span class="annottext">map (Point s BlockChain)
</span><a href="#local-6989586621681042051"><span class="hs-identifier hs-var">m0</span></a></span></span><span> </span><span id="local-6989586621681042050"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042050"><span class="hs-identifier hs-var">chain</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-487"></span><span>                </span><span id="local-6989586621681042049"><span class="annot"><span class="annottext">Point s BlockChain
</span><a href="#local-6989586621681042049"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; ST s (Point s BlockChain)
forall a s. a -&gt; ST s (Point s a)
</span><a href="GHC.Data.UnionFind.html#fresh"><span class="hs-identifier hs-var">fresh</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042050"><span class="hs-identifier hs-var">chain</span></a></span><span>
</span><span id="line-488"></span><span>                </span><span class="annot"><span class="annottext">map (Point s BlockChain) -&gt; ST s (map (Point s BlockChain))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(map (Point s BlockChain) -&gt; ST s (map (Point s BlockChain)))
-&gt; map (Point s BlockChain) -&gt; ST s (map (Point s BlockChain))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(map (Point s BlockChain) -&gt; BlockId -&gt; map (Point s BlockChain))
-&gt; map (Point s BlockChain)
-&gt; BlockChain
-&gt; map (Point s BlockChain)
forall b. (b -&gt; BlockId -&gt; b) -&gt; b -&gt; BlockChain -&gt; b
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainFoldl"><span class="hs-identifier hs-var">chainFoldl</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681042047"><span class="annot"><span class="annottext">map (Point s BlockChain)
</span><a href="#local-6989586621681042047"><span class="hs-identifier hs-var">m'</span></a></span></span><span> </span><span id="local-6989586621681042046"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042046"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">KeyOf map
-&gt; Point s BlockChain
-&gt; map (Point s BlockChain)
-&gt; map (Point s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf map
BlockId
</span><a href="#local-6989586621681042046"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">Point s BlockChain
</span><a href="#local-6989586621681042049"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">map (Point s BlockChain)
</span><a href="#local-6989586621681042047"><span class="hs-identifier hs-var">m'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">map (Point s BlockChain)
</span><a href="#local-6989586621681042051"><span class="hs-identifier hs-var">m0</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042050"><span class="hs-identifier hs-var">chain</span></a></span><span>
</span><span id="line-489"></span><span>        </span><span id="local-6989586621681042045"><span class="annot"><span class="annottext">LabelMap (Point s BlockChain)
</span><a href="#local-6989586621681042045"><span class="hs-identifier hs-var">chainMap'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(LabelMap (Point s BlockChain)
 -&gt; BlockChain -&gt; ST s (LabelMap (Point s BlockChain)))
-&gt; LabelMap (Point s BlockChain)
-&gt; [BlockChain]
-&gt; ST s (LabelMap (Point s BlockChain))
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Control.Monad.html#foldM"><span class="hs-identifier hs-var">foldM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681042044"><span class="annot"><span class="annottext">LabelMap (Point s BlockChain)
</span><a href="#local-6989586621681042044"><span class="hs-identifier hs-var">m0</span></a></span></span><span> </span><span id="local-6989586621681042043"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042043"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">LabelMap (Point s BlockChain)
-&gt; BlockChain -&gt; ST s (LabelMap (Point s BlockChain))
forall {map :: * -&gt; *} {s}.
(IsMap map, KeyOf map ~ BlockId) =&gt;
map (Point s BlockChain)
-&gt; BlockChain -&gt; ST s (map (Point s BlockChain))
</span><a href="#local-6989586621681042052"><span class="hs-identifier hs-var">addChain</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Point s BlockChain)
</span><a href="#local-6989586621681042044"><span class="hs-identifier hs-var">m0</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681042043"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap (Point s BlockChain)
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681042070"><span class="hs-identifier hs-var">chains</span></a></span><span>
</span><span id="line-490"></span><span>        </span><span class="annot"><span class="annottext">[CfgEdge] -&gt; LabelMap (Point s BlockChain) -&gt; ST s BlockChain
forall s.
[CfgEdge] -&gt; LabelMap (Point s BlockChain) -&gt; ST s BlockChain
</span><a href="#local-6989586621681042041"><span class="hs-identifier hs-var">merge</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681042071"><span class="hs-identifier hs-var">edges</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Point s BlockChain)
</span><a href="#local-6989586621681042045"><span class="hs-identifier hs-var">chainMap'</span></a></span><span>
</span><span id="line-491"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-492"></span><span>        </span><span class="hs-comment">-- We keep a map from ALL blocks to their respective chain (sigh)</span><span>
</span><span id="line-493"></span><span>        </span><span class="hs-comment">-- This is required since when looking at an edge we need to find</span><span>
</span><span id="line-494"></span><span>        </span><span class="hs-comment">-- the associated chains quickly.</span><span>
</span><span id="line-495"></span><span>        </span><span class="hs-comment">-- We use a union-find data structure to do this efficiently.</span><span>
</span><span id="line-496"></span><span>
</span><span id="line-497"></span><span>        </span><span class="annot"><a href="#local-6989586621681042041"><span class="hs-identifier hs-type">merge</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621681042452"><span class="annot"><a href="#local-6989586621681042452"><span class="hs-identifier hs-type">s</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.UnionFind.html#Point"><span class="hs-identifier hs-type">Point</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042452"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042452"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span>
</span><span id="line-498"></span><span>        </span><span id="local-6989586621681042041"><span class="annot"><span class="annottext">merge :: forall s.
[CfgEdge] -&gt; LabelMap (Point s BlockChain) -&gt; ST s BlockChain
</span><a href="#local-6989586621681042041"><span class="hs-identifier hs-var hs-var">merge</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621681042012"><span class="annot"><span class="annottext">LabelMap (Point s BlockChain)
</span><a href="#local-6989586621681042012"><span class="hs-identifier hs-var">chains</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-499"></span><span>            </span><span id="local-6989586621681042011"><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681042011"><span class="hs-identifier hs-var">chains'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Point s BlockChain -&gt; ST s BlockChain)
-&gt; [Point s BlockChain] -&gt; ST s [BlockChain]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Point s BlockChain -&gt; ST s BlockChain
forall s a. Point s a -&gt; ST s a
</span><a href="GHC.Data.UnionFind.html#find"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="annot"><span class="annottext">([Point s BlockChain] -&gt; ST s [BlockChain])
-&gt; ST s [Point s BlockChain] -&gt; ST s [BlockChain]
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Point s BlockChain] -&gt; [Point s BlockChain]
forall a. Eq a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#nub"><span class="hs-identifier hs-var">nub</span></a></span><span> </span><span class="annot"><span class="annottext">([Point s BlockChain] -&gt; [Point s BlockChain])
-&gt; ST s [Point s BlockChain] -&gt; ST s [Point s BlockChain]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Point s BlockChain -&gt; ST s (Point s BlockChain))
-&gt; [Point s BlockChain] -&gt; ST s [Point s BlockChain]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Point s BlockChain -&gt; ST s (Point s BlockChain)
forall s a. Point s a -&gt; ST s (Point s a)
</span><a href="GHC.Data.UnionFind.html#repr"><span class="hs-identifier hs-var">repr</span></a></span><span> </span><span class="annot"><span class="annottext">([Point s BlockChain] -&gt; ST s [Point s BlockChain])
-&gt; [Point s BlockChain] -&gt; ST s [Point s BlockChain]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Point s BlockChain) -&gt; [Point s BlockChain]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [a]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapElems"><span class="hs-identifier hs-var">mapElems</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Point s BlockChain)
</span><a href="#local-6989586621681042012"><span class="hs-identifier hs-var">chains</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042452"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-500"></span><span>            </span><span class="annot"><span class="annottext">BlockChain -&gt; ST s BlockChain
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(BlockChain -&gt; ST s BlockChain) -&gt; BlockChain -&gt; ST s BlockChain
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(BlockChain -&gt; BlockChain -&gt; BlockChain)
-&gt; BlockChain -&gt; [BlockChain] -&gt; BlockChain
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; BlockChain -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainConcat"><span class="hs-identifier hs-var">chainConcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockChain] -&gt; BlockChain
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681042011"><span class="hs-identifier hs-var">chains'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockChain] -&gt; [BlockChain]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#tail"><span class="hs-identifier hs-var">tail</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681042011"><span class="hs-identifier hs-var">chains'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-501"></span><span>        </span><span class="annot"><a href="#local-6989586621681042041"><span class="hs-identifier hs-var">merge</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span id="local-6989586621681042004"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042004"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681042003"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681042003"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681042002"><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681042002"><span class="hs-identifier hs-var">edges</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681042001"><span class="annot"><span class="annottext">LabelMap (Point s BlockChain)
</span><a href="#local-6989586621681042001"><span class="hs-identifier hs-var">chains</span></a></span></span><span>
</span><span id="line-502"></span><span>        </span><span class="hs-comment">--   | pprTrace &quot;merge&quot; (ppr (from,to) &lt;&gt; ppr chains) False</span><span>
</span><span id="line-503"></span><span>        </span><span class="hs-comment">--   = undefined</span><span>
</span><span id="line-504"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-505"></span><span>            </span><span id="local-6989586621681042000"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681042000"><span class="hs-identifier hs-var">same</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Point s BlockChain -&gt; Point s BlockChain -&gt; ST s Bool
forall s a. Point s a -&gt; Point s a -&gt; ST s Bool
</span><a href="GHC.Data.UnionFind.html#equivalent"><span class="hs-identifier hs-var">equivalent</span></a></span><span> </span><span class="annot"><span class="annottext">Point s BlockChain
</span><a href="#local-6989586621681041998"><span class="hs-identifier hs-var">cFrom</span></a></span><span> </span><span class="annot"><span class="annottext">Point s BlockChain
</span><a href="#local-6989586621681041997"><span class="hs-identifier hs-var">cTo</span></a></span><span>
</span><span id="line-506"></span><span>            </span><span class="annot"><span class="annottext">Bool -&gt; ST s () -&gt; ST s ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681042000"><span class="hs-identifier hs-var">same</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s () -&gt; ST s ()) -&gt; ST s () -&gt; ST s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-507"></span><span>              </span><span id="local-6989586621681041996"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041996"><span class="hs-identifier hs-var">cRight</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Point s BlockChain -&gt; ST s BlockChain
forall s a. Point s a -&gt; ST s a
</span><a href="GHC.Data.UnionFind.html#find"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="annot"><span class="annottext">Point s BlockChain
</span><a href="#local-6989586621681041997"><span class="hs-identifier hs-var">cTo</span></a></span><span>
</span><span id="line-508"></span><span>              </span><span id="local-6989586621681041995"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041995"><span class="hs-identifier hs-var">cLeft</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Point s BlockChain -&gt; ST s BlockChain
forall s a. Point s a -&gt; ST s a
</span><a href="GHC.Data.UnionFind.html#find"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="annot"><span class="annottext">Point s BlockChain
</span><a href="#local-6989586621681041998"><span class="hs-identifier hs-var">cFrom</span></a></span><span>
</span><span id="line-509"></span><span>              </span><span id="local-6989586621681041994"><span class="annot"><span class="annottext">Point s BlockChain
</span><a href="#local-6989586621681041994"><span class="hs-identifier hs-var">new_point</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; ST s (Point s BlockChain)
forall a s. a -&gt; ST s (Point s a)
</span><a href="GHC.Data.UnionFind.html#fresh"><span class="hs-identifier hs-var">fresh</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockChain -&gt; BlockChain -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainConcat"><span class="hs-identifier hs-var">chainConcat</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041995"><span class="hs-identifier hs-var">cLeft</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041996"><span class="hs-identifier hs-var">cRight</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-510"></span><span>              </span><span class="annot"><span class="annottext">Point s BlockChain -&gt; Point s BlockChain -&gt; ST s ()
forall s a. Point s a -&gt; Point s a -&gt; ST s ()
</span><a href="GHC.Data.UnionFind.html#union"><span class="hs-identifier hs-var">union</span></a></span><span> </span><span class="annot"><span class="annottext">Point s BlockChain
</span><a href="#local-6989586621681041997"><span class="hs-identifier hs-var">cTo</span></a></span><span> </span><span class="annot"><span class="annottext">Point s BlockChain
</span><a href="#local-6989586621681041994"><span class="hs-identifier hs-var">new_point</span></a></span><span>
</span><span id="line-511"></span><span>              </span><span class="annot"><span class="annottext">Point s BlockChain -&gt; Point s BlockChain -&gt; ST s ()
forall s a. Point s a -&gt; Point s a -&gt; ST s ()
</span><a href="GHC.Data.UnionFind.html#union"><span class="hs-identifier hs-var">union</span></a></span><span> </span><span class="annot"><span class="annottext">Point s BlockChain
</span><a href="#local-6989586621681041998"><span class="hs-identifier hs-var">cFrom</span></a></span><span> </span><span class="annot"><span class="annottext">Point s BlockChain
</span><a href="#local-6989586621681041994"><span class="hs-identifier hs-var">new_point</span></a></span><span>
</span><span id="line-512"></span><span>            </span><span class="annot"><span class="annottext">[CfgEdge] -&gt; LabelMap (Point s BlockChain) -&gt; ST s BlockChain
forall s.
[CfgEdge] -&gt; LabelMap (Point s BlockChain) -&gt; ST s BlockChain
</span><a href="#local-6989586621681042041"><span class="hs-identifier hs-var">merge</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681042002"><span class="hs-identifier hs-var">edges</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Point s BlockChain)
</span><a href="#local-6989586621681042001"><span class="hs-identifier hs-var">chains</span></a></span><span>
</span><span id="line-513"></span><span>          </span><span class="hs-keyword">where</span><span>
</span><span id="line-514"></span><span>            </span><span id="local-6989586621681041998"><span class="annot"><span class="annottext">cFrom :: Point s BlockChain
</span><a href="#local-6989586621681041998"><span class="hs-identifier hs-var hs-var">cFrom</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe (Point s BlockChain) -&gt; Point s BlockChain
forall a. HasCallStack =&gt; String -&gt; Maybe a -&gt; a
</span><a href="GHC.Data.Maybe.html#expectJust"><span class="hs-identifier hs-var">expectJust</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;mergeChains:chainMap:from&quot;</span></span><span> </span><span class="annot"><span class="annottext">(Maybe (Point s BlockChain) -&gt; Point s BlockChain)
-&gt; Maybe (Point s BlockChain) -&gt; Point s BlockChain
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; LabelMap (Point s BlockChain) -&gt; Maybe (Point s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681042004"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Point s BlockChain)
</span><a href="#local-6989586621681042001"><span class="hs-identifier hs-var">chains</span></a></span><span>
</span><span id="line-515"></span><span>            </span><span id="local-6989586621681041997"><span class="annot"><span class="annottext">cTo :: Point s BlockChain
</span><a href="#local-6989586621681041997"><span class="hs-identifier hs-var hs-var">cTo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe (Point s BlockChain) -&gt; Point s BlockChain
forall a. HasCallStack =&gt; String -&gt; Maybe a -&gt; a
</span><a href="GHC.Data.Maybe.html#expectJust"><span class="hs-identifier hs-var">expectJust</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;mergeChains:chainMap:to&quot;</span></span><span>   </span><span class="annot"><span class="annottext">(Maybe (Point s BlockChain) -&gt; Point s BlockChain)
-&gt; Maybe (Point s BlockChain) -&gt; Point s BlockChain
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; LabelMap (Point s BlockChain) -&gt; Maybe (Point s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681042003"><span class="hs-identifier hs-var">to</span></a></span><span>   </span><span class="annot"><span class="annottext">LabelMap (Point s BlockChain)
</span><a href="#local-6989586621681042001"><span class="hs-identifier hs-var">chains</span></a></span><span>
</span><span id="line-516"></span><span>
</span><span id="line-517"></span><span>
</span><span id="line-518"></span><span class="hs-comment">-- See Note [Chain based CFG serialization] for the general idea.</span><span>
</span><span id="line-519"></span><span class="hs-comment">-- This creates and fuses chains at the same time for performance reasons.</span><span>
</span><span id="line-520"></span><span>
</span><span id="line-521"></span><span class="hs-comment">-- Try to build chains from a list of edges.</span><span>
</span><span id="line-522"></span><span class="hs-comment">-- Edges must be sorted **descending** by their priority.</span><span>
</span><span id="line-523"></span><span class="hs-comment">-- Returns the constructed chains, along with all edges which</span><span>
</span><span id="line-524"></span><span class="hs-comment">-- are irrelevant past this point, this information doesn't need</span><span>
</span><span id="line-525"></span><span class="hs-comment">-- to be complete - it's only used to speed up the process.</span><span>
</span><span id="line-526"></span><span class="hs-comment">-- An Edge is irrelevant if the ends are part of the same chain.</span><span>
</span><span id="line-527"></span><span class="hs-comment">-- We say these edges are already linked</span><span>
</span><span id="line-528"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#buildChains"><span class="hs-identifier hs-type">buildChains</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-529"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span>  </span><span class="hs-comment">-- Resulting chains, indexd by end if chain.</span><span>
</span><span id="line-530"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.Internal.html#Set"><span class="hs-identifier hs-type">Set.Set</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-comment">--List of fused edges.</span><span>
</span><span id="line-531"></span><span id="buildChains"><span class="annot"><span class="annottext">buildChains :: [CfgEdge]
-&gt; [BlockId] -&gt; (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="GHC.CmmToAsm.BlockLayout.html#buildChains"><span class="hs-identifier hs-var hs-var">buildChains</span></a></span></span><span> </span><span id="local-6989586621681041990"><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041990"><span class="hs-identifier hs-var">edges</span></a></span></span><span> </span><span id="local-6989586621681041989"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041989"><span class="hs-identifier hs-var">blocks</span></a></span></span><span>
</span><span id="line-532"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(forall s. ST s (LabelMap BlockChain, Set (BlockId, BlockId)))
-&gt; (LabelMap BlockChain, Set (BlockId, BlockId))
forall a. (forall s. ST s a) -&gt; a
</span><a href="../../base/src/GHC.ST.html#runST"><span class="hs-identifier hs-var">runST</span></a></span><span> </span><span class="annot"><span class="annottext">((forall s. ST s (LabelMap BlockChain, Set (BlockId, BlockId)))
 -&gt; (LabelMap BlockChain, Set (BlockId, BlockId)))
-&gt; (forall s. ST s (LabelMap BlockChain, Set (BlockId, BlockId)))
-&gt; (LabelMap BlockChain, Set (BlockId, BlockId))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
forall s.
LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041984"><span class="hs-identifier hs-var">buildNext</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
forall set. IsSet set =&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setEmpty"><span class="hs-identifier hs-var">setEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041990"><span class="hs-identifier hs-var">edges</span></a></span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
forall a. Set a
</span><a href="../../containers/src/Data.Set.Internal.html#empty"><span class="hs-identifier hs-var">Set.empty</span></a></span><span>
</span><span id="line-533"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-534"></span><span>    </span><span class="hs-comment">-- buildNext builds up chains from edges one at a time.</span><span>
</span><span id="line-535"></span><span>
</span><span id="line-536"></span><span>    </span><span class="hs-comment">-- We keep a map from the ends of chains to the chains.</span><span>
</span><span id="line-537"></span><span>    </span><span class="hs-comment">-- This way we can easily check if an block should be appended to an</span><span>
</span><span id="line-538"></span><span>    </span><span class="hs-comment">-- existing chain!</span><span>
</span><span id="line-539"></span><span>    </span><span class="hs-comment">-- We store them using STRefs so we don't have to rebuild the spine of both</span><span>
</span><span id="line-540"></span><span>    </span><span class="hs-comment">-- maps every time we update a chain.</span><span>
</span><span id="line-541"></span><span>    </span><span class="annot"><a href="#local-6989586621681041984"><span class="hs-identifier hs-type">buildNext</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621681042419"><span class="annot"><a href="#local-6989586621681042419"><span class="hs-identifier hs-type">s</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-542"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.STRef.html#STRef"><span class="hs-identifier hs-type">STRef</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042419"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Map from end of chain to chain.</span><span>
</span><span id="line-543"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.STRef.html#STRef"><span class="hs-identifier hs-type">STRef</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042419"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Map from start of chain to chain.</span><span>
</span><span id="line-544"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- Edges to check - ordered by decreasing weight</span><span>
</span><span id="line-545"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.Internal.html#Set"><span class="hs-identifier hs-type">Set.Set</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Used edges</span><span>
</span><span id="line-546"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042419"><span class="hs-identifier hs-type">s</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-comment">-- Chains by end</span><span>
</span><span id="line-547"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.Internal.html#Set"><span class="hs-identifier hs-type">Set.Set</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">--List of fused edges</span><span>
</span><span id="line-548"></span><span>                        </span><span class="hs-special">)</span><span>
</span><span id="line-549"></span><span>    </span><span id="local-6989586621681041984"><span class="annot"><span class="annottext">buildNext :: forall s.
LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041984"><span class="hs-identifier hs-var hs-var">buildNext</span></a></span></span><span> </span><span id="local-6989586621681041933"><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041933"><span class="hs-identifier hs-var">placed</span></a></span></span><span> </span><span id="local-6989586621681041932"><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041932"><span class="hs-identifier hs-var">_chainStarts</span></a></span></span><span> </span><span id="local-6989586621681041931"><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041931"><span class="hs-identifier hs-var">chainEnds</span></a></span></span><span>  </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621681041930"><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041930"><span class="hs-identifier hs-var">linked</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-550"></span><span>        </span><span id="local-6989586621681041929"><span class="annot"><span class="annottext">LabelMap BlockChain
</span><a href="#local-6989586621681041929"><span class="hs-identifier hs-var">ends'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LabelMap (ST s BlockChain) -&gt; ST s (LabelMap BlockChain)
forall (t :: * -&gt; *) (m :: * -&gt; *) a.
(Traversable t, Monad m) =&gt;
t (m a) -&gt; m (t a)
</span><a href="../../base/src/Data.Traversable.html#sequence"><span class="hs-identifier hs-var">sequence</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap (ST s BlockChain) -&gt; ST s (LabelMap BlockChain))
-&gt; LabelMap (ST s BlockChain) -&gt; ST s (LabelMap BlockChain)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(STRef s BlockChain -&gt; ST s BlockChain)
-&gt; LabelMap (STRef s BlockChain) -&gt; LabelMap (ST s BlockChain)
forall (map :: * -&gt; *) a b. IsMap map =&gt; (a -&gt; b) -&gt; map a -&gt; map b
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapMap"><span class="hs-identifier hs-var">mapMap</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain -&gt; ST s BlockChain
forall s a. STRef s a -&gt; ST s a
</span><a href="../../base/src/GHC.STRef.html#readSTRef"><span class="hs-identifier hs-var">readSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041931"><span class="hs-identifier hs-var">chainEnds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042419"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-551"></span><span>        </span><span class="hs-comment">-- Any remaining blocks have to be made to singleton chains.</span><span>
</span><span id="line-552"></span><span>        </span><span class="hs-comment">-- They might be combined with other chains later on outside this function.</span><span>
</span><span id="line-553"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041925"><span class="annot"><span class="annottext">unplaced :: [BlockId]
</span><a href="#local-6989586621681041925"><span class="hs-identifier hs-var hs-var">unplaced</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(BlockId -&gt; Bool) -&gt; [BlockId] -&gt; [BlockId]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681041924"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041924"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; Bool
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#setMember"><span class="hs-identifier hs-var">setMember</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
BlockId
</span><a href="#local-6989586621681041924"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041933"><span class="hs-identifier hs-var">placed</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041989"><span class="hs-identifier hs-var">blocks</span></a></span><span>
</span><span id="line-554"></span><span>            </span><span id="local-6989586621681041922"><span class="annot"><span class="annottext">singletons :: [(BlockId, BlockChain)]
</span><a href="#local-6989586621681041922"><span class="hs-identifier hs-var hs-var">singletons</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(BlockId -&gt; (BlockId, BlockChain))
-&gt; [BlockId] -&gt; [(BlockId, BlockChain)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681041921"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041921"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041921"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockId -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainSingleton"><span class="hs-identifier hs-var">chainSingleton</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041921"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041925"><span class="hs-identifier hs-var">unplaced</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-555"></span><span>        </span><span class="annot"><span class="annottext">(LabelMap BlockChain, Set (BlockId, BlockId))
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(LabelMap BlockChain
 -&gt; (BlockId, BlockChain) -&gt; LabelMap BlockChain)
-&gt; LabelMap BlockChain
-&gt; [(BlockId, BlockChain)]
-&gt; LabelMap BlockChain
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681041920"><span class="annot"><span class="annottext">LabelMap BlockChain
</span><a href="#local-6989586621681041920"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681041919"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041919"><span class="hs-identifier hs-var">k</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681041918"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041918"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; BlockChain -&gt; LabelMap BlockChain -&gt; LabelMap BlockChain
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041919"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041918"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap BlockChain
</span><a href="#local-6989586621681041920"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap BlockChain
</span><a href="#local-6989586621681041929"><span class="hs-identifier hs-var">ends'</span></a></span><span> </span><span class="annot"><span class="annottext">[(BlockId, BlockChain)]
</span><a href="#local-6989586621681041922"><span class="hs-identifier hs-var">singletons</span></a></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041930"><span class="hs-identifier hs-var">linked</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-556"></span><span>    </span><span class="annot"><a href="#local-6989586621681041984"><span class="hs-identifier hs-var">buildNext</span></a></span><span> </span><span id="local-6989586621681041917"><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041917"><span class="hs-identifier hs-var">placed</span></a></span></span><span> </span><span id="local-6989586621681041916"><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041916"><span class="hs-identifier hs-var">chainStarts</span></a></span></span><span> </span><span id="local-6989586621681041915"><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041915"><span class="hs-identifier hs-var">chainEnds</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681041914"><span class="annot"><span class="annottext">CfgEdge
</span><a href="#local-6989586621681041914"><span class="hs-identifier hs-var">edge</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681041913"><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041913"><span class="hs-identifier hs-var">todo</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681041912"><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041912"><span class="hs-identifier hs-var">linked</span></a></span></span><span>
</span><span id="line-557"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; BlockId -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span>
</span><span id="line-558"></span><span>        </span><span class="hs-comment">-- We skip self edges</span><span>
</span><span id="line-559"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
forall s.
LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041984"><span class="hs-identifier hs-var">buildNext</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041917"><span class="hs-identifier hs-var">placed</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041916"><span class="hs-identifier hs-var">chainStarts</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041915"><span class="hs-identifier hs-var">chainEnds</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041913"><span class="hs-identifier hs-var">todo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(BlockId, BlockId)
-&gt; Set (BlockId, BlockId) -&gt; Set (BlockId, BlockId)
forall a. Ord a =&gt; a -&gt; Set a -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#insert"><span class="hs-identifier hs-var">Set.insert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041912"><span class="hs-identifier hs-var">linked</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-560"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Bool
</span><a href="#local-6989586621681041909"><span class="hs-identifier hs-var">alreadyPlaced</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-561"></span><span>          </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Bool
</span><a href="#local-6989586621681041909"><span class="hs-identifier hs-var">alreadyPlaced</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-562"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-563"></span><span>            </span><span class="hs-comment">--pprTraceM &quot;Edge-Chain:&quot; (ppr edge)</span><span>
</span><span id="line-564"></span><span>            </span><span id="local-6989586621681041908"><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041908"><span class="hs-identifier hs-var">chain'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; ST s (STRef s BlockChain)
forall a s. a -&gt; ST s (STRef s a)
</span><a href="../../base/src/GHC.STRef.html#newSTRef"><span class="hs-identifier hs-var">newSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">(BlockChain -&gt; ST s (STRef s BlockChain))
-&gt; BlockChain -&gt; ST s (STRef s BlockChain)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId] -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainFromList"><span class="hs-identifier hs-var">chainFromList</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-565"></span><span>            </span><span class="annot"><span class="annottext">LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
forall s.
LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041984"><span class="hs-identifier hs-var">buildNext</span></a></span><span>
</span><span id="line-566"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setInsert"><span class="hs-identifier hs-var">setInsert</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setInsert"><span class="hs-identifier hs-var">setInsert</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041917"><span class="hs-identifier hs-var">placed</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-567"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; STRef s BlockChain
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041908"><span class="hs-identifier hs-var">chain'</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041916"><span class="hs-identifier hs-var">chainStarts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-568"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; STRef s BlockChain
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041908"><span class="hs-identifier hs-var">chain'</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041915"><span class="hs-identifier hs-var">chainEnds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-569"></span><span>                </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041913"><span class="hs-identifier hs-var">todo</span></a></span><span>
</span><span id="line-570"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(BlockId, BlockId)
-&gt; Set (BlockId, BlockId) -&gt; Set (BlockId, BlockId)
forall a. Ord a =&gt; a -&gt; Set a -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#insert"><span class="hs-identifier hs-var">Set.insert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041912"><span class="hs-identifier hs-var">linked</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-571"></span><span>
</span><span id="line-572"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Bool
</span><a href="#local-6989586621681041909"><span class="hs-identifier hs-var">alreadyPlaced</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-573"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Bool
</span><a href="#local-6989586621681041909"><span class="hs-identifier hs-var">alreadyPlaced</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-574"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681041905"><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041905"><span class="hs-identifier hs-var">predChain</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; LabelMap (STRef s BlockChain) -&gt; Maybe (STRef s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041915"><span class="hs-identifier hs-var">chainEnds</span></a></span><span>
</span><span id="line-575"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681041904"><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041904"><span class="hs-identifier hs-var">succChain</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; LabelMap (STRef s BlockChain) -&gt; Maybe (STRef s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041916"><span class="hs-identifier hs-var">chainStarts</span></a></span><span>
</span><span id="line-576"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041905"><span class="hs-identifier hs-var">predChain</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain -&gt; STRef s BlockChain -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041904"><span class="hs-identifier hs-var">succChain</span></a></span><span> </span><span class="hs-comment">-- Otherwise we try to create a cycle.</span><span>
</span><span id="line-577"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-578"></span><span>            </span><span class="hs-comment">-- pprTraceM &quot;Fusing edge&quot; (ppr edge)</span><span>
</span><span id="line-579"></span><span>            </span><span class="annot"><span class="annottext">STRef s BlockChain
-&gt; STRef s BlockChain
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041903"><span class="hs-identifier hs-var">fuseChain</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041905"><span class="hs-identifier hs-var">predChain</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041904"><span class="hs-identifier hs-var">succChain</span></a></span><span>
</span><span id="line-580"></span><span>
</span><span id="line-581"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Bool
</span><a href="#local-6989586621681041909"><span class="hs-identifier hs-var">alreadyPlaced</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-582"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Bool
</span><a href="#local-6989586621681041909"><span class="hs-identifier hs-var">alreadyPlaced</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-583"></span><span>        </span><span class="hs-glyph">=</span><span>   </span><span class="hs-comment">--pprTraceM &quot;Skipping:&quot; (ppr edge) &gt;&gt;</span><span>
</span><span id="line-584"></span><span>            </span><span class="annot"><span class="annottext">LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
forall s.
LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041984"><span class="hs-identifier hs-var">buildNext</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041917"><span class="hs-identifier hs-var">placed</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041916"><span class="hs-identifier hs-var">chainStarts</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041915"><span class="hs-identifier hs-var">chainEnds</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041913"><span class="hs-identifier hs-var">todo</span></a></span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041912"><span class="hs-identifier hs-var">linked</span></a></span><span>
</span><span id="line-585"></span><span>
</span><span id="line-586"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-587"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-comment">-- pprTraceM &quot;Finding chain for:&quot; (ppr edge $$</span><span>
</span><span id="line-588"></span><span>             </span><span class="hs-comment">--         text &quot;placed&quot; &lt;+&gt; ppr placed)</span><span>
</span><span id="line-589"></span><span>             </span><span class="annot"><span class="annottext">ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041902"><span class="hs-identifier hs-var">findChain</span></a></span><span>
</span><span id="line-590"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-591"></span><span>        </span><span id="local-6989586621681041911"><span class="annot"><span class="annottext">from :: BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var hs-var">from</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CfgEdge -&gt; BlockId
</span><a href="GHC.CmmToAsm.CFG.html#edgeFrom"><span class="hs-identifier hs-var hs-var">edgeFrom</span></a></span><span> </span><span class="annot"><span class="annottext">CfgEdge
</span><a href="#local-6989586621681041914"><span class="hs-identifier hs-var">edge</span></a></span><span>
</span><span id="line-592"></span><span>        </span><span id="local-6989586621681041910"><span class="annot"><span class="annottext">to :: BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var hs-var">to</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CfgEdge -&gt; BlockId
</span><a href="GHC.CmmToAsm.CFG.html#edgeTo"><span class="hs-identifier hs-var hs-var">edgeTo</span></a></span><span>   </span><span class="annot"><span class="annottext">CfgEdge
</span><a href="#local-6989586621681041914"><span class="hs-identifier hs-var">edge</span></a></span><span>
</span><span id="line-593"></span><span>        </span><span id="local-6989586621681041909"><span class="annot"><span class="annottext">alreadyPlaced :: BlockId -&gt; Bool
</span><a href="#local-6989586621681041909"><span class="hs-identifier hs-var hs-var">alreadyPlaced</span></a></span></span><span> </span><span id="local-6989586621681041899"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041899"><span class="hs-identifier hs-var">blkId</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; Bool
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#setMember"><span class="hs-identifier hs-var">setMember</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
BlockId
</span><a href="#local-6989586621681041899"><span class="hs-identifier hs-var">blkId</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041917"><span class="hs-identifier hs-var">placed</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-594"></span><span>
</span><span id="line-595"></span><span>        </span><span class="hs-comment">-- Combine two chains into a single one.</span><span>
</span><span id="line-596"></span><span>        </span><span class="annot"><a href="#local-6989586621681041903"><span class="hs-identifier hs-type">fuseChain</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.STRef.html#STRef"><span class="hs-identifier hs-type">STRef</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042419"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.STRef.html#STRef"><span class="hs-identifier hs-type">STRef</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042419"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span>
</span><span id="line-597"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042419"><span class="hs-identifier hs-type">s</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-comment">-- Chains by end</span><span>
</span><span id="line-598"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.Internal.html#Set"><span class="hs-identifier hs-type">Set.Set</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">--List of fused edges</span><span>
</span><span id="line-599"></span><span>                            </span><span class="hs-special">)</span><span>
</span><span id="line-600"></span><span>        </span><span id="local-6989586621681041903"><span class="annot"><span class="annottext">fuseChain :: STRef s BlockChain
-&gt; STRef s BlockChain
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041903"><span class="hs-identifier hs-var hs-var">fuseChain</span></a></span></span><span> </span><span id="local-6989586621681041898"><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041898"><span class="hs-identifier hs-var">fromRef</span></a></span></span><span> </span><span id="local-6989586621681041897"><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041897"><span class="hs-identifier hs-var">toRef</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-601"></span><span>            </span><span id="local-6989586621681041896"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041896"><span class="hs-identifier hs-var">fromChain</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain -&gt; ST s BlockChain
forall s a. STRef s a -&gt; ST s a
</span><a href="../../base/src/GHC.STRef.html#readSTRef"><span class="hs-identifier hs-var">readSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041898"><span class="hs-identifier hs-var">fromRef</span></a></span><span>
</span><span id="line-602"></span><span>            </span><span id="local-6989586621681041895"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041895"><span class="hs-identifier hs-var">toChain</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain -&gt; ST s BlockChain
forall s a. STRef s a -&gt; ST s a
</span><a href="../../base/src/GHC.STRef.html#readSTRef"><span class="hs-identifier hs-var">readSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041897"><span class="hs-identifier hs-var">toRef</span></a></span><span>
</span><span id="line-603"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041894"><span class="annot"><span class="annottext">newChain :: BlockChain
</span><a href="#local-6989586621681041894"><span class="hs-identifier hs-var hs-var">newChain</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; BlockChain -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainConcat"><span class="hs-identifier hs-var">chainConcat</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041896"><span class="hs-identifier hs-var">fromChain</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041895"><span class="hs-identifier hs-var">toChain</span></a></span><span>
</span><span id="line-604"></span><span>            </span><span id="local-6989586621681041893"><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041893"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; ST s (STRef s BlockChain)
forall a s. a -&gt; ST s (STRef s a)
</span><a href="../../base/src/GHC.STRef.html#newSTRef"><span class="hs-identifier hs-var">newSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041894"><span class="hs-identifier hs-var">newChain</span></a></span><span>
</span><span id="line-605"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041892"><span class="annot"><span class="annottext">start :: BlockId
</span><a href="#local-6989586621681041892"><span class="hs-identifier hs-var hs-var">start</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[BlockId] -&gt; BlockId
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">([BlockId] -&gt; BlockId) -&gt; [BlockId] -&gt; BlockId
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; BlockChain -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.BlockLayout.html#takeL"><span class="hs-identifier hs-var">takeL</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041894"><span class="hs-identifier hs-var">newChain</span></a></span><span>
</span><span id="line-606"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041891"><span class="annot"><span class="annottext">end :: BlockId
</span><a href="#local-6989586621681041891"><span class="hs-identifier hs-var hs-var">end</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[BlockId] -&gt; BlockId
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">([BlockId] -&gt; BlockId) -&gt; [BlockId] -&gt; BlockId
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; BlockChain -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.BlockLayout.html#takeR"><span class="hs-identifier hs-var">takeR</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041894"><span class="hs-identifier hs-var">newChain</span></a></span><span>
</span><span id="line-607"></span><span>            </span><span class="hs-comment">-- chains &lt;- sequence $ mapMap readSTRef chainStarts</span><span>
</span><span id="line-608"></span><span>            </span><span class="hs-comment">-- pprTraceM &quot;pre-fuse chains:&quot; $ ppr chains</span><span>
</span><span id="line-609"></span><span>            </span><span class="annot"><span class="annottext">LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
forall s.
LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041984"><span class="hs-identifier hs-var">buildNext</span></a></span><span>
</span><span id="line-610"></span><span>                </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041917"><span class="hs-identifier hs-var">placed</span></a></span><span>
</span><span id="line-611"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; STRef s BlockChain
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041892"><span class="hs-identifier hs-var">start</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041893"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain))
-&gt; LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapDelete"><span class="hs-identifier hs-var">mapDelete</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain))
-&gt; LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041916"><span class="hs-identifier hs-var">chainStarts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-612"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; STRef s BlockChain
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041891"><span class="hs-identifier hs-var">end</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041893"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain))
-&gt; LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapDelete"><span class="hs-identifier hs-var">mapDelete</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain))
-&gt; LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041915"><span class="hs-identifier hs-var">chainEnds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-613"></span><span>                </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041913"><span class="hs-identifier hs-var">todo</span></a></span><span>
</span><span id="line-614"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(BlockId, BlockId)
-&gt; Set (BlockId, BlockId) -&gt; Set (BlockId, BlockId)
forall a. Ord a =&gt; a -&gt; Set a -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#insert"><span class="hs-identifier hs-var">Set.insert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041912"><span class="hs-identifier hs-var">linked</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-615"></span><span>
</span><span id="line-616"></span><span>
</span><span id="line-617"></span><span>        </span><span class="hs-comment">--Add the block to a existing chain or creates a new chain</span><span>
</span><span id="line-618"></span><span>        </span><span class="annot"><a href="#local-6989586621681041902"><span class="hs-identifier hs-type">findChain</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042419"><span class="hs-identifier hs-type">s</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#BlockChain"><span class="hs-identifier hs-type">BlockChain</span></a></span><span> </span><span class="hs-comment">-- Chains by end</span><span>
</span><span id="line-619"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.Internal.html#Set"><span class="hs-identifier hs-type">Set.Set</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">--List of fused edges</span><span>
</span><span id="line-620"></span><span>                            </span><span class="hs-special">)</span><span>
</span><span id="line-621"></span><span>        </span><span id="local-6989586621681041902"><span class="annot"><span class="annottext">findChain :: ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041902"><span class="hs-identifier hs-var hs-var">findChain</span></a></span></span><span>
</span><span id="line-622"></span><span>          </span><span class="hs-comment">-- We can attach the block to the end of a chain</span><span>
</span><span id="line-623"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; Bool
</span><a href="#local-6989586621681041890"><span class="hs-identifier hs-var">alreadyPlaced</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span>
</span><span id="line-624"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681041889"><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041889"><span class="hs-identifier hs-var">predChain</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; LabelMap (STRef s BlockChain) -&gt; Maybe (STRef s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041915"><span class="hs-identifier hs-var">chainEnds</span></a></span><span>
</span><span id="line-625"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-626"></span><span>            </span><span id="local-6989586621681041888"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041888"><span class="hs-identifier hs-var">chain</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain -&gt; ST s BlockChain
forall s a. STRef s a -&gt; ST s a
</span><a href="../../base/src/GHC.STRef.html#readSTRef"><span class="hs-identifier hs-var">readSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041889"><span class="hs-identifier hs-var">predChain</span></a></span><span>
</span><span id="line-627"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041887"><span class="annot"><span class="annottext">newChain :: BlockChain
</span><a href="#local-6989586621681041887"><span class="hs-identifier hs-var hs-var">newChain</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; BlockId -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainSnoc"><span class="hs-identifier hs-var">chainSnoc</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041888"><span class="hs-identifier hs-var">chain</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span>
</span><span id="line-628"></span><span>            </span><span class="annot"><span class="annottext">STRef s BlockChain -&gt; BlockChain -&gt; ST s ()
forall s a. STRef s a -&gt; a -&gt; ST s ()
</span><a href="../../base/src/GHC.STRef.html#writeSTRef"><span class="hs-identifier hs-var">writeSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041889"><span class="hs-identifier hs-var">predChain</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041887"><span class="hs-identifier hs-var">newChain</span></a></span><span>
</span><span id="line-629"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041885"><span class="annot"><span class="annottext">chainEnds' :: LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041885"><span class="hs-identifier hs-var hs-var">chainEnds'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; STRef s BlockChain
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041889"><span class="hs-identifier hs-var">predChain</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain))
-&gt; LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapDelete"><span class="hs-identifier hs-var">mapDelete</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041915"><span class="hs-identifier hs-var">chainEnds</span></a></span><span>
</span><span id="line-630"></span><span>            </span><span class="hs-comment">-- chains &lt;- sequence $ mapMap readSTRef chainStarts</span><span>
</span><span id="line-631"></span><span>            </span><span class="hs-comment">-- pprTraceM &quot;from chains:&quot; $ ppr chains</span><span>
</span><span id="line-632"></span><span>            </span><span class="annot"><span class="annottext">LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
forall s.
LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041984"><span class="hs-identifier hs-var">buildNext</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setInsert"><span class="hs-identifier hs-var">setInsert</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041917"><span class="hs-identifier hs-var">placed</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041916"><span class="hs-identifier hs-var">chainStarts</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041885"><span class="hs-identifier hs-var">chainEnds'</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041913"><span class="hs-identifier hs-var">todo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(BlockId, BlockId)
-&gt; Set (BlockId, BlockId) -&gt; Set (BlockId, BlockId)
forall a. Ord a =&gt; a -&gt; Set a -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#insert"><span class="hs-identifier hs-var">Set.insert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041912"><span class="hs-identifier hs-var">linked</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-633"></span><span>          </span><span class="hs-comment">-- We can attack it to the front of a chain</span><span>
</span><span id="line-634"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; Bool
</span><a href="#local-6989586621681041890"><span class="hs-identifier hs-var">alreadyPlaced</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span>
</span><span id="line-635"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681041884"><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041884"><span class="hs-identifier hs-var">succChain</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; LabelMap (STRef s BlockChain) -&gt; Maybe (STRef s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041916"><span class="hs-identifier hs-var">chainStarts</span></a></span><span>
</span><span id="line-636"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-637"></span><span>            </span><span id="local-6989586621681041883"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041883"><span class="hs-identifier hs-var">chain</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain -&gt; ST s BlockChain
forall s a. STRef s a -&gt; ST s a
</span><a href="../../base/src/GHC.STRef.html#readSTRef"><span class="hs-identifier hs-var">readSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041884"><span class="hs-identifier hs-var">succChain</span></a></span><span>
</span><span id="line-638"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041882"><span class="annot"><span class="annottext">newChain :: BlockChain
</span><a href="#local-6989586621681041882"><span class="hs-identifier hs-var hs-var">newChain</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; BlockChain -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainCons"><span class="hs-operator hs-var">`chainCons`</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041883"><span class="hs-identifier hs-var">chain</span></a></span><span>
</span><span id="line-639"></span><span>            </span><span class="annot"><span class="annottext">STRef s BlockChain -&gt; BlockChain -&gt; ST s ()
forall s a. STRef s a -&gt; a -&gt; ST s ()
</span><a href="../../base/src/GHC.STRef.html#writeSTRef"><span class="hs-identifier hs-var">writeSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041884"><span class="hs-identifier hs-var">succChain</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041882"><span class="hs-identifier hs-var">newChain</span></a></span><span>
</span><span id="line-640"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041881"><span class="annot"><span class="annottext">chainStarts' :: LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041881"><span class="hs-identifier hs-var hs-var">chainStarts'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; STRef s BlockChain
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041884"><span class="hs-identifier hs-var">succChain</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain))
-&gt; LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; LabelMap (STRef s BlockChain) -&gt; LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapDelete"><span class="hs-identifier hs-var">mapDelete</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041916"><span class="hs-identifier hs-var">chainStarts</span></a></span><span>
</span><span id="line-641"></span><span>            </span><span class="hs-comment">-- chains &lt;- sequence $ mapMap readSTRef chainStarts'</span><span>
</span><span id="line-642"></span><span>            </span><span class="hs-comment">-- pprTraceM &quot;to chains:&quot; $ ppr chains</span><span>
</span><span id="line-643"></span><span>            </span><span class="annot"><span class="annottext">LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
forall s.
LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041984"><span class="hs-identifier hs-var">buildNext</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setInsert"><span class="hs-identifier hs-var">setInsert</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041917"><span class="hs-identifier hs-var">placed</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041881"><span class="hs-identifier hs-var">chainStarts'</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041915"><span class="hs-identifier hs-var">chainEnds</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041913"><span class="hs-identifier hs-var">todo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(BlockId, BlockId)
-&gt; Set (BlockId, BlockId) -&gt; Set (BlockId, BlockId)
forall a. Ord a =&gt; a -&gt; Set a -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#insert"><span class="hs-identifier hs-var">Set.insert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041912"><span class="hs-identifier hs-var">linked</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-644"></span><span>          </span><span class="hs-comment">-- The placed end of the edge is part of a chain already and not an end.</span><span>
</span><span id="line-645"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-646"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-647"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041880"><span class="annot"><span class="annottext">block :: BlockId
</span><a href="#local-6989586621681041880"><span class="hs-identifier hs-var hs-var">block</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; Bool
</span><a href="#local-6989586621681041890"><span class="hs-identifier hs-var">alreadyPlaced</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041911"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041910"><span class="hs-identifier hs-var">to</span></a></span><span>
</span><span id="line-648"></span><span>            </span><span class="hs-comment">--pprTraceM &quot;Singleton&quot; $ ppr block</span><span>
</span><span id="line-649"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041879"><span class="annot"><span class="annottext">newChain :: BlockChain
</span><a href="#local-6989586621681041879"><span class="hs-identifier hs-var hs-var">newChain</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainSingleton"><span class="hs-identifier hs-var">chainSingleton</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041880"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-650"></span><span>            </span><span id="local-6989586621681041878"><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041878"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; ST s (STRef s BlockChain)
forall a s. a -&gt; ST s (STRef s a)
</span><a href="../../base/src/GHC.STRef.html#newSTRef"><span class="hs-identifier hs-var">newSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041879"><span class="hs-identifier hs-var">newChain</span></a></span><span>
</span><span id="line-651"></span><span>            </span><span class="annot"><span class="annottext">LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
forall s.
LabelSet
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
-&gt; [CfgEdge]
-&gt; Set (BlockId, BlockId)
-&gt; ST s (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="#local-6989586621681041984"><span class="hs-identifier hs-var">buildNext</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setInsert"><span class="hs-identifier hs-var">setInsert</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
BlockId
</span><a href="#local-6989586621681041880"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041917"><span class="hs-identifier hs-var">placed</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; STRef s BlockChain
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041880"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041878"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041916"><span class="hs-identifier hs-var">chainStarts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-652"></span><span>                      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; STRef s BlockChain
-&gt; LabelMap (STRef s BlockChain)
-&gt; LabelMap (STRef s BlockChain)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041880"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s BlockChain
</span><a href="#local-6989586621681041878"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (STRef s BlockChain)
</span><a href="#local-6989586621681041915"><span class="hs-identifier hs-var">chainEnds</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041913"><span class="hs-identifier hs-var">todo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041912"><span class="hs-identifier hs-var">linked</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-653"></span><span>            </span><span class="hs-keyword">where</span><span>
</span><span id="line-654"></span><span>              </span><span id="local-6989586621681041890"><span class="annot"><span class="annottext">alreadyPlaced :: BlockId -&gt; Bool
</span><a href="#local-6989586621681041890"><span class="hs-identifier hs-var hs-var">alreadyPlaced</span></a></span></span><span> </span><span id="local-6989586621681041877"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041877"><span class="hs-identifier hs-var">blkId</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; Bool
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#setMember"><span class="hs-identifier hs-var">setMember</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
BlockId
</span><a href="#local-6989586621681041877"><span class="hs-identifier hs-var">blkId</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041917"><span class="hs-identifier hs-var">placed</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-655"></span><span>
</span><span id="line-656"></span><span class="hs-comment">-- | Place basic blocks based on the given CFG.</span><span>
</span><span id="line-657"></span><span class="hs-comment">-- See Note [Chain based CFG serialization]</span><span>
</span><span id="line-658"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#sequenceChain"><span class="hs-identifier hs-type">sequenceChain</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621681042400"><span class="annot"><a href="#local-6989586621681042400"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span id="local-6989586621681042402"><span class="annot"><a href="#local-6989586621681042402"><span class="hs-identifier hs-type">i</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042402"><span class="hs-identifier hs-type">i</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042402"><span class="hs-identifier hs-type">i</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-659"></span><span>              </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042400"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-comment">-- ^ Keys indicate an info table on the block.</span><span>
</span><span id="line-660"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-comment">-- ^ Control flow graph and some meta data.</span><span>
</span><span id="line-661"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier hs-type">GenBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042402"><span class="hs-identifier hs-type">i</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- ^ List of basic blocks to be placed.</span><span>
</span><span id="line-662"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier hs-type">GenBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042402"><span class="hs-identifier hs-type">i</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- ^ Blocks placed in sequence.</span><span>
</span><span id="line-663"></span><span id="sequenceChain"><span class="annot"><span class="annottext">sequenceChain :: forall a i.
(Instruction i, Outputable i) =&gt;
LabelMap a -&gt; CFG -&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
</span><a href="GHC.CmmToAsm.BlockLayout.html#sequenceChain"><span class="hs-identifier hs-var hs-var">sequenceChain</span></a></span></span><span> </span><span id="local-6989586621681041840"><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681041840"><span class="hs-identifier hs-var">_info</span></a></span></span><span> </span><span id="local-6989586621681041839"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681041839"><span class="hs-identifier hs-var">_weights</span></a></span></span><span>    </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-664"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#sequenceChain"><span class="hs-identifier hs-var">sequenceChain</span></a></span><span> </span><span id="local-6989586621681041838"><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681041838"><span class="hs-identifier hs-var">_info</span></a></span></span><span> </span><span id="local-6989586621681041837"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681041837"><span class="hs-identifier hs-var">_weights</span></a></span></span><span>    </span><span class="hs-special">[</span><span id="local-6989586621681041836"><span class="annot"><span class="annottext">GenBasicBlock i
</span><a href="#local-6989586621681041836"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">GenBasicBlock i
</span><a href="#local-6989586621681041836"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-665"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#sequenceChain"><span class="hs-identifier hs-var">sequenceChain</span></a></span><span>  </span><span id="local-6989586621681041835"><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681041835"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span id="local-6989586621681041834"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681041834"><span class="hs-identifier hs-var">weights</span></a></span></span><span>     </span><span id="local-6989586621681041833"><span class="annot"><span class="annottext">blocks :: [GenBasicBlock i]
</span><a href="#local-6989586621681041833"><span class="hs-identifier hs-var">blocks</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-type">BasicBlock</span></a></span><span> </span><span id="local-6989586621681041831"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041831"><span class="hs-identifier hs-var">entry</span></a></span></span><span> </span><span class="annot"><span class="annottext">[i]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[GenBasicBlock i]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-666"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span class="annot"><a href="#local-6989586621681041830"><span class="hs-identifier hs-type">directEdges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-667"></span><span>        </span><span id="local-6989586621681041830"><span class="annot"><span class="annottext">directEdges :: [CfgEdge]
</span><a href="#local-6989586621681041830"><span class="hs-identifier hs-var hs-var">directEdges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CfgEdge -&gt; CfgEdge -&gt; Ordering) -&gt; [CfgEdge] -&gt; [CfgEdge]
forall a. (a -&gt; a -&gt; Ordering) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sortBy"><span class="hs-identifier hs-var">sortBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CfgEdge -&gt; CfgEdge -&gt; Ordering) -&gt; CfgEdge -&gt; CfgEdge -&gt; Ordering
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">CfgEdge -&gt; CfgEdge -&gt; Ordering
forall a. Ord a =&gt; a -&gt; a -&gt; Ordering
</span><span class="hs-identifier hs-var">compare</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([CfgEdge] -&gt; [CfgEdge]) -&gt; [CfgEdge] -&gt; [CfgEdge]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe CfgEdge] -&gt; [CfgEdge]
forall a. [Maybe a] -&gt; [a]
</span><a href="../../base/src/Data.Maybe.html#catMaybes"><span class="hs-identifier hs-var">catMaybes</span></a></span><span> </span><span class="annot"><span class="annottext">([Maybe CfgEdge] -&gt; [CfgEdge])
-&gt; ([CfgEdge] -&gt; [Maybe CfgEdge]) -&gt; [CfgEdge] -&gt; [CfgEdge]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(CfgEdge -&gt; Maybe CfgEdge) -&gt; [CfgEdge] -&gt; [Maybe CfgEdge]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">CfgEdge -&gt; Maybe CfgEdge
</span><a href="#local-6989586621681041827"><span class="hs-identifier hs-var">relevantWeight</span></a></span><span> </span><span class="annot"><span class="annottext">([CfgEdge] -&gt; [CfgEdge]) -&gt; [CfgEdge] -&gt; [CfgEdge]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CFG -&gt; [CfgEdge]
</span><a href="GHC.CmmToAsm.CFG.html#infoEdgeList"><span class="hs-identifier hs-var">infoEdgeList</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681041834"><span class="hs-identifier hs-var">weights</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-668"></span><span>          </span><span class="hs-keyword">where</span><span>
</span><span id="line-669"></span><span>            </span><span class="hs-comment">-- Apply modifiers to turn edge frequencies into useable weights</span><span>
</span><span id="line-670"></span><span>            </span><span class="hs-comment">-- for computing code layout.</span><span>
</span><span id="line-671"></span><span>            </span><span class="hs-comment">-- See also Note [Layout relevant edge weights]</span><span>
</span><span id="line-672"></span><span>            </span><span class="annot"><a href="#local-6989586621681041827"><span class="hs-identifier hs-type">relevantWeight</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span>
</span><span id="line-673"></span><span>            </span><span id="local-6989586621681041827"><span class="annot"><span class="annottext">relevantWeight :: CfgEdge -&gt; Maybe CfgEdge
</span><a href="#local-6989586621681041827"><span class="hs-identifier hs-var hs-var">relevantWeight</span></a></span></span><span> </span><span id="local-6989586621681041825"><span class="annot"><span class="annottext">edge :: CfgEdge
</span><a href="#local-6989586621681041825"><span class="hs-identifier hs-var">edge</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span id="local-6989586621681041824"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041824"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681041823"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041823"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621681041822"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681041822"><span class="hs-identifier hs-var">edgeInfo</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-674"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CmmSource"><span class="hs-identifier hs-type">CmmSource</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">trans_cmmNode :: TransitionSource -&gt; CmmNode O C
</span><a href="GHC.CmmToAsm.CFG.html#trans_cmmNode"><span class="hs-identifier hs-var">trans_cmmNode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmCall"><span class="hs-identifier hs-type">CmmCall</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681041822"><span class="hs-identifier hs-var">edgeInfo</span></a></span><span>
</span><span id="line-675"></span><span>                </span><span class="hs-comment">-- Ignore edges across calls.</span><span>
</span><span id="line-676"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe CfgEdge
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-677"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap a -&gt; Bool
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapMember"><span class="hs-identifier hs-var">mapMember</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041823"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681041835"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-678"></span><span>                </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681041814"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681041814"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681041822"><span class="hs-identifier hs-var">edgeInfo</span></a></span><span>
</span><span id="line-679"></span><span>                </span><span class="hs-comment">-- The payoff is quite small if we jump over an info table</span><span>
</span><span id="line-680"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CfgEdge -&gt; Maybe CfgEdge
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; BlockId -&gt; EdgeInfo -&gt; CfgEdge
</span><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-var">CfgEdge</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041824"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041823"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681041822"><span class="hs-identifier hs-var">edgeInfo</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">edgeWeight :: EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var">edgeWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681041814"><span class="hs-identifier hs-var">w</span></a></span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">8</span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-681"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CmmSource"><span class="hs-identifier hs-type">CmmSource</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">trans_cmmNode :: TransitionSource -&gt; CmmNode O C
</span><a href="GHC.CmmToAsm.CFG.html#trans_cmmNode"><span class="hs-identifier hs-var">trans_cmmNode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681041811"><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681041811"><span class="hs-identifier hs-var">exitNode</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681041822"><span class="hs-identifier hs-var">edgeInfo</span></a></span><span>
</span><span id="line-682"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmNode O C -&gt; Bool
forall {e :: Extensibility} {x :: Extensibility}.
CmmNode e x -&gt; Bool
</span><a href="#local-6989586621681041810"><span class="hs-identifier hs-var">cantEliminate</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681041811"><span class="hs-identifier hs-var">exitNode</span></a></span><span>
</span><span id="line-683"></span><span>                </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681041809"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681041809"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681041822"><span class="hs-identifier hs-var">edgeInfo</span></a></span><span>
</span><span id="line-684"></span><span>                </span><span class="hs-comment">-- A small penalty to edge types which</span><span>
</span><span id="line-685"></span><span>                </span><span class="hs-comment">-- we can't optimize away by layout.</span><span>
</span><span id="line-686"></span><span>                </span><span class="hs-comment">-- w * 0.96875 == w - w/32</span><span>
</span><span id="line-687"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CfgEdge -&gt; Maybe CfgEdge
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; BlockId -&gt; EdgeInfo -&gt; CfgEdge
</span><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-var">CfgEdge</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041824"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041823"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681041822"><span class="hs-identifier hs-var">edgeInfo</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">edgeWeight :: EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var">edgeWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681041809"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0.96875</span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-688"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-689"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CfgEdge -&gt; Maybe CfgEdge
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">CfgEdge
</span><a href="#local-6989586621681041825"><span class="hs-identifier hs-var">edge</span></a></span><span>
</span><span id="line-690"></span><span>                </span><span class="hs-keyword">where</span><span>
</span><span id="line-691"></span><span>                  </span><span id="local-6989586621681041810"><span class="annot"><span class="annottext">cantEliminate :: CmmNode e x -&gt; Bool
</span><a href="#local-6989586621681041810"><span class="hs-identifier hs-var hs-var">cantEliminate</span></a></span></span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmCondBranch"><span class="hs-identifier hs-type">CmmCondBranch</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-692"></span><span>                  </span><span class="annot"><a href="#local-6989586621681041810"><span class="hs-identifier hs-var">cantEliminate</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmSwitch"><span class="hs-identifier hs-type">CmmSwitch</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-693"></span><span>                  </span><span class="annot"><a href="#local-6989586621681041810"><span class="hs-identifier hs-var">cantEliminate</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode e x
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-694"></span><span>
</span><span id="line-695"></span><span>        </span><span class="annot"><a href="#local-6989586621681041801"><span class="hs-identifier hs-type">blockMap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier hs-type">GenBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042402"><span class="hs-identifier hs-type">i</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-696"></span><span>        </span><span id="local-6989586621681041801"><span class="annot"><span class="annottext">blockMap :: LabelMap (GenBasicBlock i)
</span><a href="#local-6989586621681041801"><span class="hs-identifier hs-var hs-var">blockMap</span></a></span></span><span>
</span><span id="line-697"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LabelMap (GenBasicBlock i)
 -&gt; GenBasicBlock i -&gt; LabelMap (GenBasicBlock i))
-&gt; LabelMap (GenBasicBlock i)
-&gt; [GenBasicBlock i]
-&gt; LabelMap (GenBasicBlock i)
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681041800"><span class="annot"><span class="annottext">LabelMap (GenBasicBlock i)
</span><a href="#local-6989586621681041800"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681041799"><span class="annot"><span class="annottext">blk :: GenBasicBlock i
</span><a href="#local-6989586621681041799"><span class="hs-identifier hs-var">blk</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-type">BasicBlock</span></a></span><span> </span><span id="local-6989586621681041798"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041798"><span class="hs-identifier hs-var">lbl</span></a></span></span><span> </span><span id="local-6989586621681041797"><span class="annot"><span class="annottext">[i]
</span><a href="#local-6989586621681041797"><span class="hs-identifier hs-var">_ins</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-698"></span><span>                        </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; GenBasicBlock i
-&gt; LabelMap (GenBasicBlock i)
-&gt; LabelMap (GenBasicBlock i)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041798"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="annot"><span class="annottext">GenBasicBlock i
</span><a href="#local-6989586621681041799"><span class="hs-identifier hs-var">blk</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (GenBasicBlock i)
</span><a href="#local-6989586621681041800"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-699"></span><span>                     </span><span class="annot"><span class="annottext">LabelMap (GenBasicBlock i)
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">[GenBasicBlock i]
</span><a href="#local-6989586621681041833"><span class="hs-identifier hs-var">blocks</span></a></span><span>
</span><span id="line-700"></span><span>
</span><span id="line-701"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681041796"><span class="annot"><span class="annottext">LabelMap BlockChain
</span><a href="#local-6989586621681041796"><span class="hs-identifier hs-var">builtChains</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681041795"><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041795"><span class="hs-identifier hs-var">builtEdges</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-702"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">&quot;buildChains&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-703"></span><span>              </span><span class="hs-comment">--pprTraceIt &quot;generatedChains&quot; $</span><span>
</span><span id="line-704"></span><span>              </span><span class="hs-comment">--pprTrace &quot;blocks&quot; (ppr (mapKeys blockMap)) $</span><span>
</span><span id="line-705"></span><span>              </span><span class="annot"><span class="annottext">[CfgEdge]
-&gt; [BlockId] -&gt; (LabelMap BlockChain, Set (BlockId, BlockId))
</span><a href="GHC.CmmToAsm.BlockLayout.html#buildChains"><span class="hs-identifier hs-var">buildChains</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041830"><span class="hs-identifier hs-var">directEdges</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LabelMap (GenBasicBlock i) -&gt; [KeyOf LabelMap]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [KeyOf map]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapKeys"><span class="hs-identifier hs-var">mapKeys</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (GenBasicBlock i)
</span><a href="#local-6989586621681041801"><span class="hs-identifier hs-var">blockMap</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-706"></span><span>
</span><span id="line-707"></span><span>        </span><span class="annot"><a href="#local-6989586621681041793"><span class="hs-identifier hs-type">rankedEdges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-708"></span><span>        </span><span class="hs-comment">-- Sort descending by weight, remove fused edges</span><span>
</span><span id="line-709"></span><span>        </span><span id="local-6989586621681041793"><span class="annot"><span class="annottext">rankedEdges :: [CfgEdge]
</span><a href="#local-6989586621681041793"><span class="hs-identifier hs-var hs-var">rankedEdges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-710"></span><span>            </span><span class="annot"><span class="annottext">(CfgEdge -&gt; Bool) -&gt; [CfgEdge] -&gt; [CfgEdge]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681041792"><span class="annot"><span class="annottext">CfgEdge
</span><a href="#local-6989586621681041792"><span class="hs-identifier hs-var">edge</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(BlockId, BlockId) -&gt; Set (BlockId, BlockId) -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-identifier hs-var">Set.member</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CfgEdge -&gt; BlockId
</span><a href="GHC.CmmToAsm.CFG.html#edgeFrom"><span class="hs-identifier hs-var hs-var">edgeFrom</span></a></span><span> </span><span class="annot"><span class="annottext">CfgEdge
</span><a href="#local-6989586621681041792"><span class="hs-identifier hs-var">edge</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CfgEdge -&gt; BlockId
</span><a href="GHC.CmmToAsm.CFG.html#edgeTo"><span class="hs-identifier hs-var hs-var">edgeTo</span></a></span><span> </span><span class="annot"><span class="annottext">CfgEdge
</span><a href="#local-6989586621681041792"><span class="hs-identifier hs-var">edge</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041795"><span class="hs-identifier hs-var">builtEdges</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([CfgEdge] -&gt; [CfgEdge]) -&gt; [CfgEdge] -&gt; [CfgEdge]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-711"></span><span>            </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041830"><span class="hs-identifier hs-var">directEdges</span></a></span><span>
</span><span id="line-712"></span><span>
</span><span id="line-713"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681041790"><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681041790"><span class="hs-identifier hs-var">neighbourChains</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681041789"><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041789"><span class="hs-identifier hs-var">combined</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-714"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">noDups</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">mapElems</span><span> </span><span class="hs-identifier">builtChains</span><span class="hs-special">)</span><span>
</span><span id="line-715"></span><span>              </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">&quot;groupNeighbourChains&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-716"></span><span>            </span><span class="hs-comment">--   pprTraceIt &quot;NeighbourChains&quot; $</span><span>
</span><span id="line-717"></span><span>              </span><span class="annot"><span class="annottext">[CfgEdge] -&gt; [BlockChain] -&gt; ([BlockChain], Set (BlockId, BlockId))
</span><a href="GHC.CmmToAsm.BlockLayout.html#combineNeighbourhood"><span class="hs-identifier hs-var">combineNeighbourhood</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041793"><span class="hs-identifier hs-var">rankedEdges</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LabelMap BlockChain -&gt; [BlockChain]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [a]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapElems"><span class="hs-identifier hs-var">mapElems</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap BlockChain
</span><a href="#local-6989586621681041796"><span class="hs-identifier hs-var">builtChains</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-718"></span><span>
</span><span id="line-719"></span><span>
</span><span id="line-720"></span><span>        </span><span class="annot"><a href="#local-6989586621681041788"><span class="hs-identifier hs-type">allEdges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-721"></span><span>        </span><span id="local-6989586621681041788"><span class="annot"><span class="annottext">allEdges :: [CfgEdge]
</span><a href="#local-6989586621681041788"><span class="hs-identifier hs-var hs-var">allEdges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">allEdges</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-722"></span><span>                   </span><span class="annot"><span class="annottext">(CfgEdge -&gt; EdgeWeight) -&gt; [CfgEdge] -&gt; [CfgEdge]
forall b a. Ord b =&gt; (a -&gt; b) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sortOn"><span class="hs-identifier hs-var">sortOn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CfgEdge -&gt; EdgeWeight
</span><a href="#local-6989586621681041787"><span class="hs-identifier hs-var">relevantWeight</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([CfgEdge] -&gt; [CfgEdge]) -&gt; [CfgEdge] -&gt; [CfgEdge]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(CfgEdge -&gt; Bool) -&gt; [CfgEdge] -&gt; [CfgEdge]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; (CfgEdge -&gt; Bool) -&gt; CfgEdge -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CfgEdge -&gt; Bool
</span><a href="#local-6989586621681041786"><span class="hs-identifier hs-var">deadEdge</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([CfgEdge] -&gt; [CfgEdge]) -&gt; [CfgEdge] -&gt; [CfgEdge]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CFG -&gt; [CfgEdge]
</span><a href="GHC.CmmToAsm.CFG.html#infoEdgeList"><span class="hs-identifier hs-var">infoEdgeList</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681041834"><span class="hs-identifier hs-var">weights</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-723"></span><span>          </span><span class="hs-keyword">where</span><span>
</span><span id="line-724"></span><span>            </span><span class="annot"><a href="#local-6989586621681041786"><span class="hs-identifier hs-type">deadEdge</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-725"></span><span>            </span><span id="local-6989586621681041786"><span class="annot"><span class="annottext">deadEdge :: CfgEdge -&gt; Bool
</span><a href="#local-6989586621681041786"><span class="hs-identifier hs-var hs-var">deadEdge</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span id="local-6989586621681041785"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041785"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681041784"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041784"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041783"><span class="annot"><span class="annottext">e :: (BlockId, BlockId)
</span><a href="#local-6989586621681041783"><span class="hs-identifier hs-var hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041785"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041784"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">(BlockId, BlockId) -&gt; Set (BlockId, BlockId) -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-identifier hs-var">Set.member</span></a></span><span> </span><span class="annot"><span class="annottext">(BlockId, BlockId)
</span><a href="#local-6989586621681041783"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041789"><span class="hs-identifier hs-var">combined</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">(BlockId, BlockId) -&gt; Set (BlockId, BlockId) -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-identifier hs-var">Set.member</span></a></span><span> </span><span class="annot"><span class="annottext">(BlockId, BlockId)
</span><a href="#local-6989586621681041783"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">Set (BlockId, BlockId)
</span><a href="#local-6989586621681041795"><span class="hs-identifier hs-var">builtEdges</span></a></span><span>
</span><span id="line-726"></span><span>            </span><span class="annot"><a href="#local-6989586621681041787"><span class="hs-identifier hs-type">relevantWeight</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span>
</span><span id="line-727"></span><span>            </span><span id="local-6989586621681041787"><span class="annot"><span class="annottext">relevantWeight :: CfgEdge -&gt; EdgeWeight
</span><a href="#local-6989586621681041787"><span class="hs-identifier hs-var hs-var">relevantWeight</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681041782"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681041782"><span class="hs-identifier hs-var">edgeInfo</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-728"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CmmSource"><span class="hs-identifier hs-type">CmmSource</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">trans_cmmNode :: TransitionSource -&gt; CmmNode O C
</span><a href="GHC.CmmToAsm.CFG.html#trans_cmmNode"><span class="hs-identifier hs-var">trans_cmmNode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmCall"><span class="hs-identifier hs-type">CmmCall</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681041782"><span class="hs-identifier hs-var">edgeInfo</span></a></span><span>
</span><span id="line-729"></span><span>                </span><span class="hs-comment">-- Penalize edges across calls</span><span>
</span><span id="line-730"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681041777"><span class="hs-identifier hs-var">weight</span></a></span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">64.0</span></span><span class="hs-special">)</span><span>
</span><span id="line-731"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-732"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681041777"><span class="hs-identifier hs-var">weight</span></a></span><span>
</span><span id="line-733"></span><span>              </span><span class="hs-keyword">where</span><span>
</span><span id="line-734"></span><span>                </span><span class="hs-comment">-- negate to sort descending</span><span>
</span><span id="line-735"></span><span>                </span><span id="local-6989586621681041777"><span class="annot"><span class="annottext">weight :: EdgeWeight
</span><a href="#local-6989586621681041777"><span class="hs-identifier hs-var hs-var">weight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#negate"><span class="hs-identifier hs-var">negate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681041782"><span class="hs-identifier hs-var">edgeInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-736"></span><span>
</span><span id="line-737"></span><span>        </span><span id="local-6989586621681041776"><span class="annot"><span class="annottext">masterChain :: BlockChain
</span><a href="#local-6989586621681041776"><span class="hs-identifier hs-var hs-var">masterChain</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-738"></span><span>            </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">&quot;mergeChains&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-739"></span><span>            </span><span class="hs-comment">-- pprTraceIt &quot;MergedChains&quot; $</span><span>
</span><span id="line-740"></span><span>            </span><span class="annot"><span class="annottext">[CfgEdge] -&gt; [BlockChain] -&gt; BlockChain
</span><a href="GHC.CmmToAsm.BlockLayout.html#mergeChains"><span class="hs-identifier hs-var">mergeChains</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681041788"><span class="hs-identifier hs-var">allEdges</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681041790"><span class="hs-identifier hs-var">neighbourChains</span></a></span><span>
</span><span id="line-741"></span><span>
</span><span id="line-742"></span><span>        </span><span class="hs-comment">--Make sure the first block stays first</span><span>
</span><span id="line-743"></span><span>        </span><span id="local-6989586621681041775"><span class="annot"><span class="annottext">prepedChains :: [BlockChain]
</span><a href="#local-6989586621681041775"><span class="hs-identifier hs-var hs-var">prepedChains</span></a></span></span><span>
</span><span id="line-744"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; BlockChain -&gt; Bool
</span><a href="GHC.CmmToAsm.BlockLayout.html#inFront"><span class="hs-identifier hs-var">inFront</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041831"><span class="hs-identifier hs-var">entry</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041776"><span class="hs-identifier hs-var">masterChain</span></a></span><span>
</span><span id="line-745"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041776"><span class="hs-identifier hs-var">masterChain</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-746"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681041774"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041774"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681041773"><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041773"><span class="hs-identifier hs-var">entry</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; BlockChain -&gt; (BlockChain, BlockChain)
</span><a href="GHC.CmmToAsm.BlockLayout.html#breakChainAt"><span class="hs-identifier hs-var">breakChainAt</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041831"><span class="hs-identifier hs-var">entry</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041776"><span class="hs-identifier hs-var">masterChain</span></a></span><span>
</span><span id="line-747"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041773"><span class="hs-identifier hs-var">entry</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">BlockChain
</span><a href="#local-6989586621681041774"><span class="hs-identifier hs-var">rest</span></a></span><span class="hs-special">]</span><span class="hs-cpp">
#if __GLASGOW_HASKELL__ &lt;= 810
</span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">otherwise</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">pprPanic</span><span> </span><span class="hs-string">&quot;Entry point eliminated&quot;</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-750"></span><span>                            </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">masterChain</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-753"></span><span>        </span><span id="local-6989586621681041772"><span class="annot"><span class="annottext">blockList :: [BlockId]
</span><a href="#local-6989586621681041772"><span class="hs-identifier hs-var hs-var">blockList</span></a></span></span><span>
</span><span id="line-754"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">noDups</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">masterChain</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-755"></span><span>              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(OrdList BlockId -&gt; [BlockId]) -&gt; [OrdList BlockId] -&gt; [BlockId]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">OrdList BlockId -&gt; [BlockId]
forall a. OrdList a -&gt; [a]
</span><a href="GHC.Data.OrdList.html#fromOL"><span class="hs-identifier hs-var">fromOL</span></a></span><span> </span><span class="annot"><span class="annottext">([OrdList BlockId] -&gt; [BlockId]) -&gt; [OrdList BlockId] -&gt; [BlockId]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(BlockChain -&gt; OrdList BlockId)
-&gt; [BlockChain] -&gt; [OrdList BlockId]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">BlockChain -&gt; OrdList BlockId
</span><a href="GHC.CmmToAsm.BlockLayout.html#chainBlocks"><span class="hs-identifier hs-var hs-var">chainBlocks</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockChain]
</span><a href="#local-6989586621681041775"><span class="hs-identifier hs-var">prepedChains</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-756"></span><span>
</span><span id="line-757"></span><span>        </span><span class="hs-comment">--chainPlaced = setFromList $ map blockId blockList :: LabelSet</span><span>
</span><span id="line-758"></span><span>        </span><span id="local-6989586621681041771"><span class="annot"><span class="annottext">chainPlaced :: LabelSet
</span><a href="#local-6989586621681041771"><span class="hs-identifier hs-var hs-var">chainPlaced</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ElemOf LabelSet] -&gt; LabelSet
forall set. IsSet set =&gt; [ElemOf set] -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setFromList"><span class="hs-identifier hs-var">setFromList</span></a></span><span> </span><span class="annot"><span class="annottext">([ElemOf LabelSet] -&gt; LabelSet) -&gt; [ElemOf LabelSet] -&gt; LabelSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[ElemOf LabelSet]
[BlockId]
</span><a href="#local-6989586621681041772"><span class="hs-identifier hs-var">blockList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-759"></span><span>        </span><span id="local-6989586621681041769"><span class="annot"><span class="annottext">unplaced :: [BlockId]
</span><a href="#local-6989586621681041769"><span class="hs-identifier hs-var hs-var">unplaced</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-760"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041768"><span class="annot"><span class="annottext">blocks :: [KeyOf LabelMap]
</span><a href="#local-6989586621681041768"><span class="hs-identifier hs-var hs-var">blocks</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap (GenBasicBlock i) -&gt; [KeyOf LabelMap]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [KeyOf map]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapKeys"><span class="hs-identifier hs-var">mapKeys</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (GenBasicBlock i)
</span><a href="#local-6989586621681041801"><span class="hs-identifier hs-var">blockMap</span></a></span><span>
</span><span id="line-761"></span><span>                </span><span id="local-6989586621681041767"><span class="annot"><span class="annottext">isPlaced :: BlockId -&gt; Bool
</span><a href="#local-6989586621681041767"><span class="hs-identifier hs-var hs-var">isPlaced</span></a></span></span><span> </span><span id="local-6989586621681041766"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041766"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; Bool
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#setMember"><span class="hs-identifier hs-var">setMember</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet
BlockId
</span><a href="#local-6989586621681041766"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681041771"><span class="hs-identifier hs-var">chainPlaced</span></a></span><span>
</span><span id="line-762"></span><span>            </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">(BlockId -&gt; Bool) -&gt; [BlockId] -&gt; [BlockId]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681041765"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041765"><span class="hs-identifier hs-var">block</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Bool
</span><a href="#local-6989586621681041767"><span class="hs-identifier hs-var">isPlaced</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041765"><span class="hs-identifier hs-var">block</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[KeyOf LabelMap]
[BlockId]
</span><a href="#local-6989586621681041768"><span class="hs-identifier hs-var">blocks</span></a></span><span>
</span><span id="line-763"></span><span>
</span><span id="line-764"></span><span>        </span><span id="local-6989586621681041764"><span class="annot"><span class="annottext">placedBlocks :: [BlockId]
</span><a href="#local-6989586621681041764"><span class="hs-identifier hs-var hs-var">placedBlocks</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-765"></span><span>            </span><span class="hs-comment">-- We want debug builds to catch this as it's a good indicator for</span><span>
</span><span id="line-766"></span><span>            </span><span class="hs-comment">-- issues with CFG invariants. But we don't want to blow up production</span><span>
</span><span id="line-767"></span><span>            </span><span class="hs-comment">-- builds if something slips through.</span><span>
</span><span id="line-768"></span><span>            </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">null</span><span> </span><span class="hs-identifier">unplaced</span><span class="hs-special">)</span><span>
</span><span id="line-769"></span><span>            </span><span class="hs-comment">--pprTraceIt &quot;placedBlocks&quot; $</span><span>
</span><span id="line-770"></span><span>            </span><span class="hs-comment">-- ++ [] is stil kinda expensive</span><span>
</span><span id="line-771"></span><span>            </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[BlockId] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041769"><span class="hs-identifier hs-var">unplaced</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041772"><span class="hs-identifier hs-var">blockList</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041772"><span class="hs-identifier hs-var">blockList</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId] -&gt; [BlockId] -&gt; [BlockId]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041769"><span class="hs-identifier hs-var">unplaced</span></a></span><span>
</span><span id="line-772"></span><span>        </span><span id="local-6989586621681041763"><span class="annot"><span class="annottext">getBlock :: BlockId -&gt; GenBasicBlock i
</span><a href="#local-6989586621681041763"><span class="hs-identifier hs-var hs-var">getBlock</span></a></span></span><span> </span><span id="local-6989586621681041762"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041762"><span class="hs-identifier hs-var">bid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe (GenBasicBlock i) -&gt; GenBasicBlock i
forall a. HasCallStack =&gt; String -&gt; Maybe a -&gt; a
</span><a href="GHC.Data.Maybe.html#expectJust"><span class="hs-identifier hs-var">expectJust</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Block placement&quot;</span></span><span> </span><span class="annot"><span class="annottext">(Maybe (GenBasicBlock i) -&gt; GenBasicBlock i)
-&gt; Maybe (GenBasicBlock i) -&gt; GenBasicBlock i
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; LabelMap (GenBasicBlock i) -&gt; Maybe (GenBasicBlock i)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041762"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (GenBasicBlock i)
</span><a href="#local-6989586621681041801"><span class="hs-identifier hs-var">blockMap</span></a></span><span>
</span><span id="line-773"></span><span>    </span><span class="hs-keyword">in</span><span>
</span><span id="line-774"></span><span>        </span><span class="hs-comment">--Assert we placed all blocks given as input</span><span>
</span><span id="line-775"></span><span>        </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">all</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">bid</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">mapMember</span><span> </span><span class="hs-identifier">bid</span><span> </span><span class="hs-identifier">blockMap</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">placedBlocks</span><span class="hs-special">)</span><span>
</span><span id="line-776"></span><span>        </span><span class="annot"><span class="annottext">LabelMap a -&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
forall a i.
Instruction i =&gt;
LabelMap a -&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
</span><a href="GHC.CmmToAsm.BlockLayout.html#dropJumps"><span class="hs-identifier hs-var">dropJumps</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681041835"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">([GenBasicBlock i] -&gt; [GenBasicBlock i])
-&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(BlockId -&gt; GenBasicBlock i) -&gt; [BlockId] -&gt; [GenBasicBlock i]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; GenBasicBlock i
</span><a href="#local-6989586621681041763"><span class="hs-identifier hs-var">getBlock</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041764"><span class="hs-identifier hs-var">placedBlocks</span></a></span><span>
</span><span id="line-777"></span><span>
</span><span id="line-778"></span><span class="hs-pragma">{-# SCC</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#dropJumps"><span class="hs-pragma hs-type">dropJumps</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-779"></span><span class="hs-comment">-- | Remove redundant jumps between blocks when we can rely on</span><span>
</span><span id="line-780"></span><span class="hs-comment">-- fall through.</span><span>
</span><span id="line-781"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#dropJumps"><span class="hs-identifier hs-type">dropJumps</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621681042371"><span class="annot"><a href="#local-6989586621681042371"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span id="local-6989586621681042372"><span class="annot"><a href="#local-6989586621681042372"><span class="hs-identifier hs-type">i</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042372"><span class="hs-identifier hs-type">i</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042371"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier hs-type">GenBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042372"><span class="hs-identifier hs-type">i</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-782"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier hs-type">GenBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042372"><span class="hs-identifier hs-type">i</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-783"></span><span id="dropJumps"><span class="annot"><span class="annottext">dropJumps :: forall a i.
Instruction i =&gt;
LabelMap a -&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
</span><a href="GHC.CmmToAsm.BlockLayout.html#dropJumps"><span class="hs-identifier hs-var hs-var">dropJumps</span></a></span></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><span class="hs-identifier">_</span></span><span>    </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-784"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#dropJumps"><span class="hs-identifier hs-var">dropJumps</span></a></span><span> </span><span id="local-6989586621681041751"><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681041751"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-type">BasicBlock</span></a></span><span> </span><span id="local-6989586621681041750"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041750"><span class="hs-identifier hs-var">lbl</span></a></span></span><span> </span><span id="local-6989586621681041749"><span class="annot"><span class="annottext">[i]
</span><a href="#local-6989586621681041749"><span class="hs-identifier hs-var">ins</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681041748"><span class="annot"><span class="annottext">[GenBasicBlock i]
</span><a href="#local-6989586621681041748"><span class="hs-identifier hs-var">todo</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-785"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; ([i] -&gt; Bool) -&gt; [i] -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">[i] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">([i] -&gt; Bool) -&gt; [i] -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[i]
</span><a href="#local-6989586621681041749"><span class="hs-identifier hs-var">ins</span></a></span><span> </span><span class="hs-comment">--This can happen because of shortcutting</span><span>
</span><span id="line-786"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621681041747"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041747"><span class="hs-identifier hs-var">dest</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">i -&gt; [BlockId]
forall instr. Instruction instr =&gt; instr -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.Instr.html#jumpDestsOfInstr"><span class="hs-identifier hs-var">jumpDestsOfInstr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[i] -&gt; i
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#last"><span class="hs-identifier hs-var">last</span></a></span><span> </span><span class="annot"><span class="annottext">[i]
</span><a href="#local-6989586621681041749"><span class="hs-identifier hs-var">ins</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-787"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-type">BasicBlock</span></a></span><span> </span><span id="local-6989586621681041744"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041744"><span class="hs-identifier hs-var">nextLbl</span></a></span></span><span> </span><span class="annot"><span class="annottext">[i]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span class="annot"><span class="annottext">[GenBasicBlock i]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[GenBasicBlock i]
</span><a href="#local-6989586621681041748"><span class="hs-identifier hs-var">todo</span></a></span><span>
</span><span id="line-788"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap a -&gt; Bool
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapMember"><span class="hs-identifier hs-var">mapMember</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041747"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681041751"><span class="hs-identifier hs-var">info</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-789"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041744"><span class="hs-identifier hs-var">nextLbl</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; BlockId -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041747"><span class="hs-identifier hs-var">dest</span></a></span><span>
</span><span id="line-790"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; [i] -&gt; GenBasicBlock i
forall i. BlockId -&gt; [i] -&gt; GenBasicBlock i
</span><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-var">BasicBlock</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041750"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[i] -&gt; [i]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#init"><span class="hs-identifier hs-var">init</span></a></span><span> </span><span class="annot"><span class="annottext">[i]
</span><a href="#local-6989586621681041749"><span class="hs-identifier hs-var">ins</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">GenBasicBlock i -&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">LabelMap a -&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
forall a i.
Instruction i =&gt;
LabelMap a -&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
</span><a href="GHC.CmmToAsm.BlockLayout.html#dropJumps"><span class="hs-identifier hs-var">dropJumps</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681041751"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">[GenBasicBlock i]
</span><a href="#local-6989586621681041748"><span class="hs-identifier hs-var">todo</span></a></span><span>
</span><span id="line-791"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-792"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; [i] -&gt; GenBasicBlock i
forall i. BlockId -&gt; [i] -&gt; GenBasicBlock i
</span><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-var">BasicBlock</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041750"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="annot"><span class="annottext">[i]
</span><a href="#local-6989586621681041749"><span class="hs-identifier hs-var">ins</span></a></span><span> </span><span class="annot"><span class="annottext">GenBasicBlock i -&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">LabelMap a -&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
forall a i.
Instruction i =&gt;
LabelMap a -&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
</span><a href="GHC.CmmToAsm.BlockLayout.html#dropJumps"><span class="hs-identifier hs-var">dropJumps</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681041751"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">[GenBasicBlock i]
</span><a href="#local-6989586621681041748"><span class="hs-identifier hs-var">todo</span></a></span><span>
</span><span id="line-793"></span><span>
</span><span id="line-794"></span><span>
</span><span id="line-795"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-796"></span><span class="hs-comment">-- Sequencing the basic blocks</span><span>
</span><span id="line-797"></span><span>
</span><span id="line-798"></span><span class="hs-comment">-- Cmm BasicBlocks are self-contained entities: they always end in a</span><span>
</span><span id="line-799"></span><span class="hs-comment">-- jump, either non-local or to another basic block in the same proc.</span><span>
</span><span id="line-800"></span><span class="hs-comment">-- In this phase, we attempt to place the basic blocks in a sequence</span><span>
</span><span id="line-801"></span><span class="hs-comment">-- such that as many of the local jumps as possible turn into</span><span>
</span><span id="line-802"></span><span class="hs-comment">-- fallthroughs.</span><span>
</span><span id="line-803"></span><span>
</span><span id="line-804"></span><span id="local-6989586621681042363"><span id="local-6989586621681042364"><span id="local-6989586621681042366"><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#sequenceTop"><span class="hs-identifier hs-type">sequenceTop</span></a></span><span>
</span><span id="line-805"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042366"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042366"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-806"></span><span>    </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-comment">-- Determine which layout algo to use</span><span>
</span><span id="line-807"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Monad.html#NcgImpl"><span class="hs-identifier hs-type">NcgImpl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042364"><span class="hs-identifier hs-type">statics</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042366"><span class="hs-identifier hs-type">instr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042363"><span class="hs-identifier hs-type">jumpDest</span></a></span><span>
</span><span id="line-808"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-comment">-- ^ CFG if we have one.</span><span>
</span><span id="line-809"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#NatCmmDecl"><span class="hs-identifier hs-type">NatCmmDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042364"><span class="hs-identifier hs-type">statics</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042366"><span class="hs-identifier hs-type">instr</span></a></span><span> </span><span class="hs-comment">-- ^ Function to serialize</span><span>
</span><span id="line-810"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#NatCmmDecl"><span class="hs-identifier hs-type">NatCmmDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042364"><span class="hs-identifier hs-type">statics</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042366"><span class="hs-identifier hs-type">instr</span></a></span></span></span></span><span>
</span><span id="line-811"></span><span>
</span><span id="line-812"></span><span id="sequenceTop"><span class="annot"><span class="annottext">sequenceTop :: forall instr statics jumpDest.
(Instruction instr, Outputable instr) =&gt;
DynFlags
-&gt; NcgImpl statics instr jumpDest
-&gt; Maybe CFG
-&gt; NatCmmDecl statics instr
-&gt; NatCmmDecl statics instr
</span><a href="GHC.CmmToAsm.BlockLayout.html#sequenceTop"><span class="hs-identifier hs-var hs-var">sequenceTop</span></a></span></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><span class="hs-identifier">_</span></span><span>     </span><span class="annot"><span class="annottext">NcgImpl statics instr jumpDest
</span><span class="hs-identifier">_</span></span><span>       </span><span class="annot"><span class="annottext">Maybe CFG
</span><span class="hs-identifier">_</span></span><span>           </span><span id="local-6989586621681041737"><span class="annot"><span class="annottext">top :: NatCmmDecl statics instr
</span><a href="#local-6989586621681041737"><span class="hs-identifier hs-var">top</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#CmmData"><span class="hs-identifier hs-type">CmmData</span></a></span><span> </span><span class="annot"><span class="annottext">Section
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">statics
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NatCmmDecl statics instr
</span><a href="#local-6989586621681041737"><span class="hs-identifier hs-var">top</span></a></span><span>
</span><span id="line-813"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#sequenceTop"><span class="hs-identifier hs-var">sequenceTop</span></a></span><span> </span><span id="local-6989586621681041735"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681041735"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681041734"><span class="annot"><span class="annottext">NcgImpl statics instr jumpDest
</span><a href="#local-6989586621681041734"><span class="hs-identifier hs-var">ncgImpl</span></a></span></span><span> </span><span id="local-6989586621681041733"><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681041733"><span class="hs-identifier hs-var">edgeWeights</span></a></span></span><span>
</span><span id="line-814"></span><span>            </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#CmmProc"><span class="hs-identifier hs-type">CmmProc</span></a></span><span> </span><span id="local-6989586621681041731"><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><a href="#local-6989586621681041731"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span id="local-6989586621681041730"><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681041730"><span class="hs-identifier hs-var">lbl</span></a></span></span><span> </span><span id="local-6989586621681041729"><span class="annot"><span class="annottext">[GlobalReg]
</span><a href="#local-6989586621681041729"><span class="hs-identifier hs-var">live</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#ListGraph"><span class="hs-identifier hs-type">ListGraph</span></a></span><span> </span><span id="local-6989586621681041727"><span class="annot"><span class="annottext">[GenBasicBlock instr]
</span><a href="#local-6989586621681041727"><span class="hs-identifier hs-var">blocks</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-815"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_CfgBlocklayout"><span class="hs-identifier hs-var">Opt_CfgBlocklayout</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681041735"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Bool
</span><a href="GHC.CmmToAsm.BlockLayout.html#backendMaintainsCfg"><span class="hs-identifier hs-var">backendMaintainsCfg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681041735"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-816"></span><span>  </span><span class="hs-comment">--Use chain based algorithm</span><span>
</span><span id="line-817"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681041725"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681041725"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681041733"><span class="hs-identifier hs-var">edgeWeights</span></a></span><span>
</span><span id="line-818"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
-&gt; CLabel
-&gt; [GlobalReg]
-&gt; ListGraph instr
-&gt; NatCmmDecl statics instr
forall d h g. h -&gt; CLabel -&gt; [GlobalReg] -&gt; g -&gt; GenCmmDecl d h g
</span><a href="GHC.Cmm.html#CmmProc"><span class="hs-identifier hs-var">CmmProc</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><a href="#local-6989586621681041731"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681041730"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalReg]
</span><a href="#local-6989586621681041729"><span class="hs-identifier hs-var">live</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">[GenBasicBlock instr] -&gt; ListGraph instr
forall i. [GenBasicBlock i] -&gt; ListGraph i
</span><a href="GHC.Cmm.html#ListGraph"><span class="hs-identifier hs-var">ListGraph</span></a></span><span> </span><span class="annot"><span class="annottext">([GenBasicBlock instr] -&gt; ListGraph instr)
-&gt; [GenBasicBlock instr] -&gt; ListGraph instr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">NcgImpl statics instr jumpDest
-&gt; LabelMap RawCmmStatics
-&gt; [GenBasicBlock instr]
-&gt; [GenBasicBlock instr]
forall statics instr jumpDest.
NcgImpl statics instr jumpDest
-&gt; LabelMap RawCmmStatics
-&gt; [NatBasicBlock instr]
-&gt; [NatBasicBlock instr]
</span><a href="GHC.CmmToAsm.Monad.html#ncgMakeFarBranches"><span class="hs-identifier hs-var hs-var">ncgMakeFarBranches</span></a></span><span> </span><span class="annot"><span class="annottext">NcgImpl statics instr jumpDest
</span><a href="#local-6989586621681041734"><span class="hs-identifier hs-var">ncgImpl</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><a href="#local-6989586621681041731"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">([GenBasicBlock instr] -&gt; [GenBasicBlock instr])
-&gt; [GenBasicBlock instr] -&gt; [GenBasicBlock instr]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-819"></span><span>                            </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">layoutBlocks</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-820"></span><span>                            </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
-&gt; CFG -&gt; [GenBasicBlock instr] -&gt; [GenBasicBlock instr]
forall a i.
(Instruction i, Outputable i) =&gt;
LabelMap a -&gt; CFG -&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
</span><a href="GHC.CmmToAsm.BlockLayout.html#sequenceChain"><span class="hs-identifier hs-var">sequenceChain</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><a href="#local-6989586621681041731"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681041725"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">[GenBasicBlock instr]
</span><a href="#local-6989586621681041727"><span class="hs-identifier hs-var">blocks</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-821"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-822"></span><span>  </span><span class="hs-comment">--Use old algorithm</span><span>
</span><span id="line-823"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041723"><span class="annot"><span class="annottext">cfg :: Maybe CFG
</span><a href="#local-6989586621681041723"><span class="hs-identifier hs-var hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681041722"><span class="hs-identifier hs-var">dontUseCfg</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe CFG
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681041733"><span class="hs-identifier hs-var">edgeWeights</span></a></span><span>
</span><span id="line-824"></span><span>    </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
-&gt; CLabel
-&gt; [GlobalReg]
-&gt; ListGraph instr
-&gt; NatCmmDecl statics instr
forall d h g. h -&gt; CLabel -&gt; [GlobalReg] -&gt; g -&gt; GenCmmDecl d h g
</span><a href="GHC.Cmm.html#CmmProc"><span class="hs-identifier hs-var">CmmProc</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><a href="#local-6989586621681041731"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681041730"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalReg]
</span><a href="#local-6989586621681041729"><span class="hs-identifier hs-var">live</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">[GenBasicBlock instr] -&gt; ListGraph instr
forall i. [GenBasicBlock i] -&gt; ListGraph i
</span><a href="GHC.Cmm.html#ListGraph"><span class="hs-identifier hs-var">ListGraph</span></a></span><span> </span><span class="annot"><span class="annottext">([GenBasicBlock instr] -&gt; ListGraph instr)
-&gt; [GenBasicBlock instr] -&gt; ListGraph instr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">NcgImpl statics instr jumpDest
-&gt; LabelMap RawCmmStatics
-&gt; [GenBasicBlock instr]
-&gt; [GenBasicBlock instr]
forall statics instr jumpDest.
NcgImpl statics instr jumpDest
-&gt; LabelMap RawCmmStatics
-&gt; [NatBasicBlock instr]
-&gt; [NatBasicBlock instr]
</span><a href="GHC.CmmToAsm.Monad.html#ncgMakeFarBranches"><span class="hs-identifier hs-var hs-var">ncgMakeFarBranches</span></a></span><span> </span><span class="annot"><span class="annottext">NcgImpl statics instr jumpDest
</span><a href="#local-6989586621681041734"><span class="hs-identifier hs-var">ncgImpl</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><a href="#local-6989586621681041731"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">([GenBasicBlock instr] -&gt; [GenBasicBlock instr])
-&gt; [GenBasicBlock instr] -&gt; [GenBasicBlock instr]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-825"></span><span>                                </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">layoutBlocks</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-826"></span><span>                                </span><span class="annot"><span class="annottext">Maybe CFG
-&gt; LabelMap RawCmmStatics
-&gt; [GenBasicBlock instr]
-&gt; [GenBasicBlock instr]
forall inst a.
Instruction inst =&gt;
Maybe CFG
-&gt; LabelMap a -&gt; [GenBasicBlock inst] -&gt; [GenBasicBlock inst]
</span><a href="GHC.CmmToAsm.BlockLayout.html#sequenceBlocks"><span class="hs-identifier hs-var">sequenceBlocks</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681041723"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><a href="#local-6989586621681041731"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">[GenBasicBlock instr]
</span><a href="#local-6989586621681041727"><span class="hs-identifier hs-var">blocks</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-827"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-828"></span><span>    </span><span id="local-6989586621681041722"><span class="annot"><span class="annottext">dontUseCfg :: Bool
</span><a href="#local-6989586621681041722"><span class="hs-identifier hs-var hs-var">dontUseCfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_WeightlessBlocklayout"><span class="hs-identifier hs-var">Opt_WeightlessBlocklayout</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681041735"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-829"></span><span>                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; Bool -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Bool
</span><a href="GHC.CmmToAsm.BlockLayout.html#backendMaintainsCfg"><span class="hs-identifier hs-var">backendMaintainsCfg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681041735"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-830"></span><span>
</span><span id="line-831"></span><span class="hs-comment">-- The old algorithm:</span><span>
</span><span id="line-832"></span><span class="hs-comment">-- It is very simple (and stupid): We make a graph out of</span><span>
</span><span id="line-833"></span><span class="hs-comment">-- the blocks where there is an edge from one block to another iff the</span><span>
</span><span id="line-834"></span><span class="hs-comment">-- first block ends by jumping to the second.  Then we topologically</span><span>
</span><span id="line-835"></span><span class="hs-comment">-- sort this graph.  Then traverse the list: for each block, we first</span><span>
</span><span id="line-836"></span><span class="hs-comment">-- output the block, then if it has an out edge, we move the</span><span>
</span><span id="line-837"></span><span class="hs-comment">-- destination of the out edge to the front of the list, and continue.</span><span>
</span><span id="line-838"></span><span>
</span><span id="line-839"></span><span class="hs-comment">-- FYI, the classic layout for basic blocks uses postorder DFS; this</span><span>
</span><span id="line-840"></span><span class="hs-comment">-- algorithm is implemented in Hoopl.</span><span>
</span><span id="line-841"></span><span>
</span><span id="line-842"></span><span id="local-6989586621681042340"><span id="local-6989586621681042341"><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#sequenceBlocks"><span class="hs-identifier hs-type">sequenceBlocks</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042341"><span class="hs-identifier hs-type">inst</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042340"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-843"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier hs-type">GenBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042341"><span class="hs-identifier hs-type">inst</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier hs-type">GenBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042341"><span class="hs-identifier hs-type">inst</span></a></span><span class="hs-special">]</span></span></span><span>
</span><span id="line-844"></span><span id="sequenceBlocks"><span class="annot"><span class="annottext">sequenceBlocks :: forall inst a.
Instruction inst =&gt;
Maybe CFG
-&gt; LabelMap a -&gt; [GenBasicBlock inst] -&gt; [GenBasicBlock inst]
</span><a href="GHC.CmmToAsm.BlockLayout.html#sequenceBlocks"><span class="hs-identifier hs-var hs-var">sequenceBlocks</span></a></span></span><span> </span><span id="local-6989586621681041715"><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681041715"><span class="hs-identifier hs-var">_edgeWeight</span></a></span></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-845"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#sequenceBlocks"><span class="hs-identifier hs-var">sequenceBlocks</span></a></span><span> </span><span id="local-6989586621681041714"><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681041714"><span class="hs-identifier hs-var">edgeWeights</span></a></span></span><span> </span><span id="local-6989586621681041713"><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681041713"><span class="hs-identifier hs-var">infos</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681041712"><span class="annot"><span class="annottext">GenBasicBlock inst
</span><a href="#local-6989586621681041712"><span class="hs-identifier hs-var">entry</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681041711"><span class="annot"><span class="annottext">[GenBasicBlock inst]
</span><a href="#local-6989586621681041711"><span class="hs-identifier hs-var">blocks</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-846"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681041710"><span class="annot"><span class="annottext">entryNode :: Node BlockId (GenBasicBlock inst)
</span><a href="#local-6989586621681041710"><span class="hs-identifier hs-var hs-var">entryNode</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe CFG
-&gt; GenBasicBlock inst -&gt; Node BlockId (GenBasicBlock inst)
forall t.
Instruction t =&gt;
Maybe CFG -&gt; GenBasicBlock t -&gt; Node BlockId (GenBasicBlock t)
</span><a href="GHC.CmmToAsm.BlockLayout.html#mkNode"><span class="hs-identifier hs-var">mkNode</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681041714"><span class="hs-identifier hs-var">edgeWeights</span></a></span><span> </span><span class="annot"><span class="annottext">GenBasicBlock inst
</span><a href="#local-6989586621681041712"><span class="hs-identifier hs-var">entry</span></a></span><span>
</span><span id="line-847"></span><span>        </span><span id="local-6989586621681041708"><span class="annot"><span class="annottext">bodyNodes :: [Node BlockId (GenBasicBlock inst)]
</span><a href="#local-6989586621681041708"><span class="hs-identifier hs-var hs-var">bodyNodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Node BlockId (GenBasicBlock inst)]
-&gt; [Node BlockId (GenBasicBlock inst)]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span>
</span><span id="line-848"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SCC (Node BlockId (GenBasicBlock inst))]
-&gt; [Node BlockId (GenBasicBlock inst)]
forall a. [SCC a] -&gt; [a]
</span><a href="../../containers/src/Data.Graph.html#flattenSCCs"><span class="hs-identifier hs-var">flattenSCCs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe CFG
-&gt; [GenBasicBlock inst]
-&gt; [SCC (Node BlockId (GenBasicBlock inst))]
forall instr.
Instruction instr =&gt;
Maybe CFG
-&gt; [NatBasicBlock instr]
-&gt; [SCC (Node BlockId (NatBasicBlock instr))]
</span><a href="GHC.CmmToAsm.BlockLayout.html#sccBlocks"><span class="hs-identifier hs-var">sccBlocks</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681041714"><span class="hs-identifier hs-var">edgeWeights</span></a></span><span> </span><span class="annot"><span class="annottext">[GenBasicBlock inst]
</span><a href="#local-6989586621681041711"><span class="hs-identifier hs-var">blocks</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-849"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">LabelMap a -&gt; [GenBasicBlock inst] -&gt; [GenBasicBlock inst]
forall a i.
Instruction i =&gt;
LabelMap a -&gt; [GenBasicBlock i] -&gt; [GenBasicBlock i]
</span><a href="GHC.CmmToAsm.BlockLayout.html#dropJumps"><span class="hs-identifier hs-var">dropJumps</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681041713"><span class="hs-identifier hs-var">infos</span></a></span><span> </span><span class="annot"><span class="annottext">([GenBasicBlock inst] -&gt; [GenBasicBlock inst])
-&gt; ([Node BlockId (GenBasicBlock inst)] -&gt; [GenBasicBlock inst])
-&gt; [Node BlockId (GenBasicBlock inst)]
-&gt; [GenBasicBlock inst]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a
-&gt; [Node BlockId (GenBasicBlock inst)] -&gt; [GenBasicBlock inst]
forall i t1.
LabelMap i
-&gt; [Node BlockId (GenBasicBlock t1)] -&gt; [GenBasicBlock t1]
</span><a href="GHC.CmmToAsm.BlockLayout.html#seqBlocks"><span class="hs-identifier hs-var">seqBlocks</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681041713"><span class="hs-identifier hs-var">infos</span></a></span><span> </span><span class="annot"><span class="annottext">([Node BlockId (GenBasicBlock inst)] -&gt; [GenBasicBlock inst])
-&gt; [Node BlockId (GenBasicBlock inst)] -&gt; [GenBasicBlock inst]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Node BlockId (GenBasicBlock inst)
</span><a href="#local-6989586621681041710"><span class="hs-identifier hs-var">entryNode</span></a></span><span> </span><span class="annot"><span class="annottext">Node BlockId (GenBasicBlock inst)
-&gt; [Node BlockId (GenBasicBlock inst)]
-&gt; [Node BlockId (GenBasicBlock inst)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Node BlockId (GenBasicBlock inst)]
</span><a href="#local-6989586621681041708"><span class="hs-identifier hs-var">bodyNodes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-850"></span><span>  </span><span class="hs-comment">-- the first block is the entry point ==&gt; it must remain at the start.</span><span>
</span><span id="line-851"></span><span>
</span><span id="line-852"></span><span id="local-6989586621681042333"><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#sccBlocks"><span class="hs-identifier hs-type">sccBlocks</span></a></span><span>
</span><span id="line-853"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042333"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-854"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#NatBasicBlock"><span class="hs-identifier hs-type">NatBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042333"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-855"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../containers/src/Data.Graph.html#SCC"><span class="hs-identifier hs-type">SCC</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Graph.Directed.html#Node"><span class="hs-identifier hs-type">Node</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#NatBasicBlock"><span class="hs-identifier hs-type">NatBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042333"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">]</span></span><span>
</span><span id="line-856"></span><span id="sccBlocks"><span class="annot"><span class="annottext">sccBlocks :: forall instr.
Instruction instr =&gt;
Maybe CFG
-&gt; [NatBasicBlock instr]
-&gt; [SCC (Node BlockId (NatBasicBlock instr))]
</span><a href="GHC.CmmToAsm.BlockLayout.html#sccBlocks"><span class="hs-identifier hs-var hs-var">sccBlocks</span></a></span></span><span> </span><span id="local-6989586621681041699"><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681041699"><span class="hs-identifier hs-var">edgeWeights</span></a></span></span><span> </span><span id="local-6989586621681041698"><span class="annot"><span class="annottext">[NatBasicBlock instr]
</span><a href="#local-6989586621681041698"><span class="hs-identifier hs-var">blocks</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-857"></span><span>    </span><span class="annot"><span class="annottext">[Node BlockId (NatBasicBlock instr)]
-&gt; [SCC (Node BlockId (NatBasicBlock instr))]
forall key payload.
Uniquable key =&gt;
[Node key payload] -&gt; [SCC (Node key payload)]
</span><a href="GHC.Data.Graph.Directed.html#stronglyConnCompFromEdgedVerticesUniqR"><span class="hs-identifier hs-var">stronglyConnCompFromEdgedVerticesUniqR</span></a></span><span>
</span><span id="line-858"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(NatBasicBlock instr -&gt; Node BlockId (NatBasicBlock instr))
-&gt; [NatBasicBlock instr] -&gt; [Node BlockId (NatBasicBlock instr)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe CFG
-&gt; NatBasicBlock instr -&gt; Node BlockId (NatBasicBlock instr)
forall t.
Instruction t =&gt;
Maybe CFG -&gt; GenBasicBlock t -&gt; Node BlockId (GenBasicBlock t)
</span><a href="GHC.CmmToAsm.BlockLayout.html#mkNode"><span class="hs-identifier hs-var">mkNode</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681041699"><span class="hs-identifier hs-var">edgeWeights</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[NatBasicBlock instr]
</span><a href="#local-6989586621681041698"><span class="hs-identifier hs-var">blocks</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-859"></span><span>
</span><span id="line-860"></span><span id="local-6989586621681042336"><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#mkNode"><span class="hs-identifier hs-type">mkNode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042336"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-861"></span><span>       </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier hs-type">GenBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042336"><span class="hs-identifier hs-type">t</span></a></span><span>
</span><span id="line-862"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Directed.html#Node"><span class="hs-identifier hs-type">Node</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier hs-type">GenBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042336"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-863"></span><span id="mkNode"><span class="annot"><span class="annottext">mkNode :: forall t.
Instruction t =&gt;
Maybe CFG -&gt; GenBasicBlock t -&gt; Node BlockId (GenBasicBlock t)
</span><a href="GHC.CmmToAsm.BlockLayout.html#mkNode"><span class="hs-identifier hs-var hs-var">mkNode</span></a></span></span><span> </span><span id="local-6989586621681041685"><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681041685"><span class="hs-identifier hs-var">edgeWeights</span></a></span></span><span> </span><span id="local-6989586621681041684"><span class="annot"><span class="annottext">block :: GenBasicBlock t
</span><a href="#local-6989586621681041684"><span class="hs-identifier hs-var">block</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-type">BasicBlock</span></a></span><span> </span><span id="local-6989586621681041683"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041683"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621681041682"><span class="annot"><span class="annottext">[t]
</span><a href="#local-6989586621681041682"><span class="hs-identifier hs-var">instrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-864"></span><span>    </span><span class="annot"><span class="annottext">GenBasicBlock t
-&gt; BlockId -&gt; [BlockId] -&gt; Node BlockId (GenBasicBlock t)
forall key payload. payload -&gt; key -&gt; [key] -&gt; Node key payload
</span><a href="GHC.Data.Graph.Directed.html#DigraphNode"><span class="hs-identifier hs-var">DigraphNode</span></a></span><span> </span><span class="annot"><span class="annottext">GenBasicBlock t
</span><a href="#local-6989586621681041684"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041683"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041680"><span class="hs-identifier hs-var">outEdges</span></a></span><span>
</span><span id="line-865"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-866"></span><span>    </span><span class="annot"><a href="#local-6989586621681041680"><span class="hs-identifier hs-type">outEdges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-867"></span><span>    </span><span id="local-6989586621681041680"><span class="annot"><span class="annottext">outEdges :: [BlockId]
</span><a href="#local-6989586621681041680"><span class="hs-identifier hs-var hs-var">outEdges</span></a></span></span><span>
</span><span id="line-868"></span><span>      </span><span class="hs-comment">--Select the heaviest successor, ignore weights &lt;= zero</span><span>
</span><span id="line-869"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041679"><span class="hs-identifier hs-var">successor</span></a></span><span>
</span><span id="line-870"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-871"></span><span>        </span><span id="local-6989586621681041679"><span class="annot"><span class="annottext">successor :: [BlockId]
</span><a href="#local-6989586621681041679"><span class="hs-identifier hs-var hs-var">successor</span></a></span></span><span>
</span><span id="line-872"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681041678"><span class="annot"><span class="annottext">[(BlockId, EdgeInfo)]
</span><a href="#local-6989586621681041678"><span class="hs-identifier hs-var">successors</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; [(BlockId, EdgeInfo)])
-&gt; Maybe CFG -&gt; Maybe [(BlockId, EdgeInfo)]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CFG -&gt; BlockId -&gt; [(BlockId, EdgeInfo)]
</span><a href="GHC.CmmToAsm.CFG.html#getSuccEdgesSorted"><span class="hs-operator hs-var">`getSuccEdgesSorted`</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041683"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-873"></span><span>                                    </span><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681041685"><span class="hs-identifier hs-var">edgeWeights</span></a></span><span> </span><span class="hs-comment">-- :: Maybe [(Label, EdgeInfo)]</span><span>
</span><span id="line-874"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[(BlockId, EdgeInfo)]
</span><a href="#local-6989586621681041678"><span class="hs-identifier hs-var">successors</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-875"></span><span>            </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-876"></span><span>            </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681041676"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041676"><span class="hs-identifier hs-var">target</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681041675"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681041675"><span class="hs-identifier hs-var">info</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[(BlockId, EdgeInfo)]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-877"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[(BlockId, EdgeInfo)] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[(BlockId, EdgeInfo)]
</span><a href="#local-6989586621681041678"><span class="hs-identifier hs-var">successors</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681041675"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-878"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041676"><span class="hs-identifier hs-var">target</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-879"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-880"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">t -&gt; [BlockId]
forall instr. Instruction instr =&gt; instr -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.Instr.html#jumpDestsOfInstr"><span class="hs-identifier hs-var">jumpDestsOfInstr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[t] -&gt; t
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#last"><span class="hs-identifier hs-var">last</span></a></span><span> </span><span class="annot"><span class="annottext">[t]
</span><a href="#local-6989586621681041682"><span class="hs-identifier hs-var">instrs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-881"></span><span>                </span><span class="hs-special">[</span><span id="local-6989586621681041671"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041671"><span class="hs-identifier hs-var">one</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041671"><span class="hs-identifier hs-var">one</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-882"></span><span>                </span><span id="local-6989586621681041670"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041670"><span class="hs-identifier hs-var">_many</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-883"></span><span>
</span><span id="line-884"></span><span>
</span><span id="line-885"></span><span id="local-6989586621681042331"><span id="local-6989586621681042332"><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#seqBlocks"><span class="hs-identifier hs-type">seqBlocks</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042332"><span class="hs-identifier hs-type">i</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Data.Graph.Directed.html#Node"><span class="hs-identifier hs-type">Node</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier hs-type">GenBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042331"><span class="hs-identifier hs-type">t1</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-886"></span><span>                        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier hs-type">GenBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042331"><span class="hs-identifier hs-type">t1</span></a></span><span class="hs-special">]</span></span></span><span>
</span><span id="line-887"></span><span id="seqBlocks"><span class="annot"><span class="annottext">seqBlocks :: forall i t1.
LabelMap i
-&gt; [Node BlockId (GenBasicBlock t1)] -&gt; [GenBasicBlock t1]
</span><a href="GHC.CmmToAsm.BlockLayout.html#seqBlocks"><span class="hs-identifier hs-var hs-var">seqBlocks</span></a></span></span><span> </span><span id="local-6989586621681041664"><span class="annot"><span class="annottext">LabelMap i
</span><a href="#local-6989586621681041664"><span class="hs-identifier hs-var">infos</span></a></span></span><span> </span><span id="local-6989586621681041663"><span class="annot"><span class="annottext">[Node BlockId (GenBasicBlock t1)]
</span><a href="#local-6989586621681041663"><span class="hs-identifier hs-var">blocks</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
-&gt; [BlockId] -&gt; [GenBasicBlock t1]
</span><a href="#local-6989586621681041662"><span class="hs-identifier hs-var">placeNext</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041661"><span class="hs-identifier hs-var">pullable0</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041660"><span class="hs-identifier hs-var">todo0</span></a></span><span>
</span><span id="line-888"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-889"></span><span>    </span><span class="hs-comment">-- pullable: Blocks that are not yet placed</span><span>
</span><span id="line-890"></span><span>    </span><span class="hs-comment">-- todo:     Original order of blocks, to be followed if we have no good</span><span>
</span><span id="line-891"></span><span>    </span><span class="hs-comment">--           reason not to;</span><span>
</span><span id="line-892"></span><span>    </span><span class="hs-comment">--           may include blocks that have already been placed, but then</span><span>
</span><span id="line-893"></span><span>    </span><span class="hs-comment">--           these are not in pullable</span><span>
</span><span id="line-894"></span><span>    </span><span id="local-6989586621681041661"><span class="annot"><span class="annottext">pullable0 :: UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041661"><span class="hs-identifier hs-var hs-var">pullable0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(BlockId, (GenBasicBlock t1, [BlockId]))]
-&gt; UniqFM BlockId (GenBasicBlock t1, [BlockId])
forall key elt. Uniquable key =&gt; [(key, elt)] -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#listToUFM"><span class="hs-identifier hs-var">listToUFM</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041658"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">,</span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenBasicBlock t1
</span><a href="#local-6989586621681041657"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041656"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Directed.html#DigraphNode"><span class="hs-identifier hs-type">DigraphNode</span></a></span><span> </span><span id="local-6989586621681041657"><span class="annot"><span class="annottext">GenBasicBlock t1
</span><a href="#local-6989586621681041657"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621681041658"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041658"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span id="local-6989586621681041656"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041656"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Node BlockId (GenBasicBlock t1)]
</span><a href="#local-6989586621681041663"><span class="hs-identifier hs-var">blocks</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-895"></span><span>    </span><span id="local-6989586621681041660"><span class="annot"><span class="annottext">todo0 :: [BlockId]
</span><a href="#local-6989586621681041660"><span class="hs-identifier hs-var hs-var">todo0</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Node BlockId (GenBasicBlock t1) -&gt; BlockId)
-&gt; [Node BlockId (GenBasicBlock t1)] -&gt; [BlockId]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Node BlockId (GenBasicBlock t1) -&gt; BlockId
forall key payload. Node key payload -&gt; key
</span><a href="GHC.Data.Graph.Directed.html#node_key"><span class="hs-identifier hs-var hs-var">node_key</span></a></span><span> </span><span class="annot"><span class="annottext">[Node BlockId (GenBasicBlock t1)]
</span><a href="#local-6989586621681041663"><span class="hs-identifier hs-var">blocks</span></a></span><span>
</span><span id="line-896"></span><span>
</span><span id="line-897"></span><span>    </span><span id="local-6989586621681041662"><span class="annot"><span class="annottext">placeNext :: UniqFM BlockId (GenBasicBlock t1, [BlockId])
-&gt; [BlockId] -&gt; [GenBasicBlock t1]
</span><a href="#local-6989586621681041662"><span class="hs-identifier hs-var hs-var">placeNext</span></a></span></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-898"></span><span>    </span><span class="annot"><a href="#local-6989586621681041662"><span class="hs-identifier hs-var">placeNext</span></a></span><span> </span><span id="local-6989586621681041654"><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041654"><span class="hs-identifier hs-var">pullable</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681041653"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041653"><span class="hs-identifier hs-var">i</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681041652"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041652"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-899"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681041651"><span class="annot"><span class="annottext">(GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041651"><span class="hs-identifier hs-var">block</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681041650"><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041650"><span class="hs-identifier hs-var">pullable'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
-&gt; BlockId
-&gt; Maybe
     ((GenBasicBlock t1, [BlockId]),
      UniqFM BlockId (GenBasicBlock t1, [BlockId]))
forall elt.
UniqFM BlockId elt -&gt; BlockId -&gt; Maybe (elt, UniqFM BlockId elt)
</span><a href="GHC.CmmToAsm.BlockLayout.html#lookupDeleteUFM"><span class="hs-identifier hs-var">lookupDeleteUFM</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041654"><span class="hs-identifier hs-var">pullable</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041653"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-900"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
-&gt; [BlockId] -&gt; (GenBasicBlock t1, [BlockId]) -&gt; [GenBasicBlock t1]
</span><a href="#local-6989586621681041648"><span class="hs-identifier hs-var">place</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041650"><span class="hs-identifier hs-var">pullable'</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041652"><span class="hs-identifier hs-var">rest</span></a></span><span> </span><span class="annot"><span class="annottext">(GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041651"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-901"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-902"></span><span>        </span><span class="hs-comment">-- We already placed this block, so ignore</span><span>
</span><span id="line-903"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
-&gt; [BlockId] -&gt; [GenBasicBlock t1]
</span><a href="#local-6989586621681041662"><span class="hs-identifier hs-var">placeNext</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041654"><span class="hs-identifier hs-var">pullable</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041652"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-904"></span><span>
</span><span id="line-905"></span><span>    </span><span id="local-6989586621681041648"><span class="annot"><span class="annottext">place :: UniqFM BlockId (GenBasicBlock t1, [BlockId])
-&gt; [BlockId] -&gt; (GenBasicBlock t1, [BlockId]) -&gt; [GenBasicBlock t1]
</span><a href="#local-6989586621681041648"><span class="hs-identifier hs-var hs-var">place</span></a></span></span><span> </span><span id="local-6989586621681041647"><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041647"><span class="hs-identifier hs-var">pullable</span></a></span></span><span> </span><span id="local-6989586621681041646"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041646"><span class="hs-identifier hs-var">todo</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681041645"><span class="annot"><span class="annottext">GenBasicBlock t1
</span><a href="#local-6989586621681041645"><span class="hs-identifier hs-var">block</span></a></span></span><span class="hs-special">,</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-906"></span><span>                          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GenBasicBlock t1
</span><a href="#local-6989586621681041645"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">GenBasicBlock t1 -&gt; [GenBasicBlock t1] -&gt; [GenBasicBlock t1]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
-&gt; [BlockId] -&gt; [GenBasicBlock t1]
</span><a href="#local-6989586621681041662"><span class="hs-identifier hs-var">placeNext</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041647"><span class="hs-identifier hs-var">pullable</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041646"><span class="hs-identifier hs-var">todo</span></a></span><span>
</span><span id="line-907"></span><span>    </span><span class="annot"><a href="#local-6989586621681041648"><span class="hs-identifier hs-var">place</span></a></span><span> </span><span id="local-6989586621681041644"><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041644"><span class="hs-identifier hs-var">pullable</span></a></span></span><span> </span><span id="local-6989586621681041643"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041643"><span class="hs-identifier hs-var">todo</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681041642"><span class="annot"><span class="annottext">block :: GenBasicBlock t1
</span><a href="#local-6989586621681041642"><span class="hs-identifier hs-var">block</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-type">BasicBlock</span></a></span><span> </span><span id="local-6989586621681041641"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041641"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621681041640"><span class="annot"><span class="annottext">[t1]
</span><a href="#local-6989586621681041640"><span class="hs-identifier hs-var">instrs</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="hs-special">[</span><span id="local-6989586621681041639"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041639"><span class="hs-identifier hs-var">next</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-908"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap i -&gt; Bool
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapMember"><span class="hs-identifier hs-var">mapMember</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681041639"><span class="hs-identifier hs-var">next</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap i
</span><a href="#local-6989586621681041664"><span class="hs-identifier hs-var">infos</span></a></span><span>
</span><span id="line-909"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GenBasicBlock t1
</span><a href="#local-6989586621681041642"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">GenBasicBlock t1 -&gt; [GenBasicBlock t1] -&gt; [GenBasicBlock t1]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
-&gt; [BlockId] -&gt; [GenBasicBlock t1]
</span><a href="#local-6989586621681041662"><span class="hs-identifier hs-var">placeNext</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041644"><span class="hs-identifier hs-var">pullable</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041643"><span class="hs-identifier hs-var">todo</span></a></span><span>
</span><span id="line-910"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681041638"><span class="annot"><span class="annottext">(GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041638"><span class="hs-identifier hs-var">nextBlock</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681041637"><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041637"><span class="hs-identifier hs-var">pullable'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
-&gt; BlockId
-&gt; Maybe
     ((GenBasicBlock t1, [BlockId]),
      UniqFM BlockId (GenBasicBlock t1, [BlockId]))
forall elt.
UniqFM BlockId elt -&gt; BlockId -&gt; Maybe (elt, UniqFM BlockId elt)
</span><a href="GHC.CmmToAsm.BlockLayout.html#lookupDeleteUFM"><span class="hs-identifier hs-var">lookupDeleteUFM</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041644"><span class="hs-identifier hs-var">pullable</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041639"><span class="hs-identifier hs-var">next</span></a></span><span>
</span><span id="line-911"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; [t1] -&gt; GenBasicBlock t1
forall i. BlockId -&gt; [i] -&gt; GenBasicBlock i
</span><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-var">BasicBlock</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041641"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">[t1]
</span><a href="#local-6989586621681041640"><span class="hs-identifier hs-var">instrs</span></a></span><span> </span><span class="annot"><span class="annottext">GenBasicBlock t1 -&gt; [GenBasicBlock t1] -&gt; [GenBasicBlock t1]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
-&gt; [BlockId] -&gt; (GenBasicBlock t1, [BlockId]) -&gt; [GenBasicBlock t1]
</span><a href="#local-6989586621681041648"><span class="hs-identifier hs-var">place</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041637"><span class="hs-identifier hs-var">pullable'</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041643"><span class="hs-identifier hs-var">todo</span></a></span><span> </span><span class="annot"><span class="annottext">(GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041638"><span class="hs-identifier hs-var">nextBlock</span></a></span><span>
</span><span id="line-912"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-913"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GenBasicBlock t1
</span><a href="#local-6989586621681041642"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">GenBasicBlock t1 -&gt; [GenBasicBlock t1] -&gt; [GenBasicBlock t1]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
-&gt; [BlockId] -&gt; [GenBasicBlock t1]
</span><a href="#local-6989586621681041662"><span class="hs-identifier hs-var">placeNext</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><a href="#local-6989586621681041644"><span class="hs-identifier hs-var">pullable</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041643"><span class="hs-identifier hs-var">todo</span></a></span><span>
</span><span id="line-914"></span><span>    </span><span class="annot"><a href="#local-6989586621681041648"><span class="hs-identifier hs-var">place</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (GenBasicBlock t1, [BlockId])
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenBasicBlock t1
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681041636"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041636"><span class="hs-identifier hs-var">tooManyNextNodes</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-915"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; [GenBasicBlock t1]
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;seqBlocks&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockId] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681041636"><span class="hs-identifier hs-var">tooManyNextNodes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-916"></span><span>
</span><span id="line-917"></span><span>
</span><span id="line-918"></span><span id="local-6989586621681042312"><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#lookupDeleteUFM"><span class="hs-identifier hs-type">lookupDeleteUFM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#UniqFM"><span class="hs-identifier hs-type">UniqFM</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042312"><span class="hs-identifier hs-type">elt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>
</span><span id="line-919"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621681042312"><span class="hs-identifier hs-type">elt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#UniqFM"><span class="hs-identifier hs-type">UniqFM</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681042312"><span class="hs-identifier hs-type">elt</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-920"></span><span id="lookupDeleteUFM"><span class="annot"><span class="annottext">lookupDeleteUFM :: forall elt.
UniqFM BlockId elt -&gt; BlockId -&gt; Maybe (elt, UniqFM BlockId elt)
</span><a href="GHC.CmmToAsm.BlockLayout.html#lookupDeleteUFM"><span class="hs-identifier hs-var hs-var">lookupDeleteUFM</span></a></span></span><span> </span><span id="local-6989586621681041629"><span class="annot"><span class="annottext">UniqFM BlockId elt
</span><a href="#local-6989586621681041629"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681041628"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041628"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-comment">-- Maybe monad</span><span>
</span><span id="line-921"></span><span>    </span><span id="local-6989586621681041627"><span class="annot"><span class="annottext">elt
</span><a href="#local-6989586621681041627"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId elt -&gt; BlockId -&gt; Maybe elt
forall key elt. Uniquable key =&gt; UniqFM key elt -&gt; key -&gt; Maybe elt
</span><a href="GHC.Types.Unique.FM.html#lookupUFM"><span class="hs-identifier hs-var">lookupUFM</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId elt
</span><a href="#local-6989586621681041629"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041628"><span class="hs-identifier hs-var">k</span></a></span><span>
</span><span id="line-922"></span><span>    </span><span class="annot"><span class="annottext">(elt, UniqFM BlockId elt) -&gt; Maybe (elt, UniqFM BlockId elt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">elt
</span><a href="#local-6989586621681041627"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId elt -&gt; BlockId -&gt; UniqFM BlockId elt
forall key elt.
Uniquable key =&gt;
UniqFM key elt -&gt; key -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#delFromUFM"><span class="hs-identifier hs-var">delFromUFM</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId elt
</span><a href="#local-6989586621681041629"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681041628"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-923"></span><span>
</span><span id="line-924"></span><span class="annot"><a href="GHC.CmmToAsm.BlockLayout.html#backendMaintainsCfg"><span class="hs-identifier hs-type">backendMaintainsCfg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-925"></span><span id="backendMaintainsCfg"><span class="annot"><span class="annottext">backendMaintainsCfg :: Platform -&gt; Bool
</span><a href="GHC.CmmToAsm.BlockLayout.html#backendMaintainsCfg"><span class="hs-identifier hs-var hs-var">backendMaintainsCfg</span></a></span></span><span> </span><span id="local-6989586621681041624"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681041624"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Arch
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformArch"><span class="hs-identifier hs-var">platformArch</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681041624"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-926"></span><span>    </span><span class="hs-comment">-- ArchX86 -- Should work but not tested so disabled currently.</span><span>
</span><span id="line-927"></span><span>    </span><span class="annot"><span class="annottext">Arch
</span><a href="../../ghc-boot/src/GHC.Platform.html#ArchX86_64"><span class="hs-identifier hs-var">ArchX86_64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-928"></span><span>    </span><span id="local-6989586621681041621"><span class="annot"><span class="annottext">Arch
</span><a href="#local-6989586621681041621"><span class="hs-identifier hs-var">_otherwise</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-929"></span><span>
</span><span id="line-930"></span></pre></body></html>